At 05:48 PM 9/20/1999 , Benjamin Pflugmann wrote:
>While others already gave good answers, I wanted to throw in some
>SQL operates on sets. And it is completely legal (i.e. syntactically
>and semantically correct) to write a condition which will return an
>empty set. The cited example is not much different from "WHERE 1=0"
>and there are several valid reasons why one would want to write such a
>Hm. I cannot remember any computer language where an impossible
>statement would be considered to be an error (a warning maybe, but not
>So one should put this in other words: Should MySQL warn (not fail)
>about such conditions?
>Answer: The general rule for MySQL seems to be to prefer speed before
>comfort: It is due to the programmer to execute only senseful queries
>and put only valid data in the database, i.e. perform all the checks
>she consideres nescessary.
>While I generally agree with this statement, I also already wondered
>if we cannot make MySQL a bit more comfortable for development
>systems. (e.g. let MySQL write all queries which it has some warnings
>about to a logfile, or make the mysql client (or a mysqldebug client
>:-) know and check such things or whatever).
>I don't see a solution how to integrate this in the main server
>without paying an unwanted price... but maybe someone else has a good
Just my 2 cents...
...validating queries at this level seems to be more a function of the
client program or some DB abstraction layer, rather than the MySQL
engine...after all, the query that started this thread off was perfectly
legal and in some cases perfectly sensible. I don't think it's the job of
MySQL to second-guess the programmer. If these functions were added to some
abstraction layer, query generator or GUI front-end, that would make the
most sense to me. Let's not load up MySQL with too many
speed-decreasing/memory-increasing features! This reminds me of the
periodic threads about whether MySQL should validate values in DATE type
columns, and the answer to that was, "that's the programmer's job."
+-------------------- "He's dead, Jim" - Bones McCoy --------------------+
| Steve Edberg University of California, Davis |
| sbedberg@stripped http://aesric.ucdavis.edu/ |
| (530)754-9127 |
+---------------------- DeForest Kelley 1920-1999 -----------------------+