Bug #27963 | ORDER BY ignored when SELECTing from INFORMATION_SCHEMA | ||
---|---|---|---|
Submitted: | 19 Apr 2007 20:48 | Modified: | 2 May 2007 13:15 |
Reporter: | Jay Pipes | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Information schema | Severity: | S2 (Serious) |
Version: | 5.0.42-debug-log, 5.1 | OS: | Linux (2.6.17-11) |
Assigned to: | Georgi Kodinov | CPU Architecture: | Any |
Tags: | I_S, regression |
[19 Apr 2007 20:48]
Jay Pipes
[19 Apr 2007 20:49]
Jay Pipes
Results file from 5.0.42 showing no oRDER BY honoured
Attachment: bug27963.txt (text/plain), 10.80 KiB.
[20 Apr 2007 8:06]
Sveta Smirnova
Thank you for the report. Please provide dump of your information_schema database. We can examine if this affects only Information Schema or every similar query.
[20 Apr 2007 22:29]
Sveta Smirnova
test case
Attachment: bug27963.test (application/octet-stream, text), 61.53 KiB.
[20 Apr 2007 22:36]
Sveta Smirnova
Thank you for the report. Verified as described using attached test case. Introduced in 5.0.33. Version 5.0.27 is not affected.
[2 May 2007 13:15]
Georgi Kodinov
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/ and the instructions on how to report a bug at http://bugs.mysql.com/how-to-report.php The core of the problem described here can be demonstrated by the following commands : CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (2),(1); SELECT a as "SEL" FROM t1 ORDER BY "SEL"; SET SQL_MODE="ANSI_QUOTES"; SELECT a as "SEL" FROM t1 ORDER BY "SEL"; The docs say (about quotes) : - "The identifier quote character is the backtick (“`”):" - "If the ANSI_QUOTES SQL mode is enabled, it is also allowable to quote identifiers within double quotes" - "A string is a sequence of bytes or characters, enclosed within either single quote (“'”) or double quote (“"”) characters." - "If the ANSI_QUOTES SQL mode is enabled, string literals can be quoted only within single quotes because a string quoted within double quotes is interpreted as an identifier." Taking the above into account it follows that the "SEL" in the above query is a string in non-ANSI mode (the default) and an identifier in ANSI mode. There was a bug in MySQL (bug #14019) that it was not checking the type of the reference and hence treating strings (and others) as column references to the equally named columns. This was fixed in in 4.1.22/5.0.30/5.1.13