Re: An amusing MySQL weakness--not! - Mailing list pgsql-general

From Darren Duncan
Subject Re: An amusing MySQL weakness--not!
Date
Msg-id 4E06DA56.8030905@darrenduncan.net
Whole thread Raw
In response to An amusing MySQL weakness--not!  (Michael Nolan <htfoot@gmail.com>)
Responses Re: An amusing MySQL weakness--not!
List pgsql-general
Michael Nolan wrote:
> Earlier today I was working on a MySQL database (not by choice, I assure
> you),
> and I typed a statement like this:
>
> Update tablexyz set field1 = '15' where field2 - 20;
>
> The '-' was supposed to be an equal sign, but MySQL executed it anyway.
> (Field2 is an integer.)
>
> I was not amused.
>
> PostgreSQL reports this as an error, of course.

I assume MySQL accepts this because it, like SQLite, doesn't have a real BOOLEAN
type and instead uses INTEGER for its truth values, I believe.

The result of any "foo = bar" is an INTEGER anyway, I believe, in such DBMSs,
same as "field2 - 20", and so if its result is nonzero, that is treated as TRUE.

Sure, that's inane, but for this one I would place a lot of blame on the SQL
standard, because it doesn't mandate BOOLEAN support, just making it optional,
and so lots of SQL DBMSs don't require BOOLEAN as the type of a WHERE expression.

Having real BOOLEAN is just one of the reasons I like Postgres the most.

-- Darren Duncan

pgsql-general by date:

Previous
From: merlyn@stonehenge.com (Randal L. Schwartz)
Date:
Subject: Re: An amusing MySQL weakness--not!
Next
From: Vincent Veyron
Date:
Subject: Re: An amusing MySQL weakness--not!