Commit graph

28 commits

Author SHA1 Message Date
gkodinov@mysql.com
7bae0de398 BUG#18068: SELECT DISTINCT (with duplicates and covering index)
When converting DISTINCT to GROUP BY where the columns are from the covering
index and they are quoted twice in the SELECT list the optimizer is creating
improper processing sequence. This is because of the fact that the columns
of the covering index are not recognized as such and treated as non-index
columns.

Generally speaking duplicate columns can safely be removed from the GROUP
BY/DISTINCT list because this will not add or remove new rows in the
resulting set. Duplicates can be removed even if they are not consecutive
(as is the case for ORDER BY, where the duplicate columns can be removed
only if they are consecutive).

So we can safely transform "SELECT DISTINCT a,a FROM ... ORDER BY a" to
"SELECT a,a FROM ... GROUP BY a ORDER BY a" instead of 
"SELECT a,a FROM .. GROUP BY a,a ORDER BY a". We can even transform 
"SELECT DISTINCT a,b,a FROM ... ORDER BY a,b" to
"SELECT a,b,a FROM ... GROUP BY a,b ORDER BY a,b".

The fix to this bug consists of checking for duplicate columns in the SELECT
list when constructing the GROUP BY list in transforming DISTINCT to GROUP
BY and skipping the ones that are already in.
2006-05-09 18:13:01 +03:00
holyfoot@deer.(none)
a920d0df86 bug #15745 (COUNT(DISTINCT CONCAT(x,y)) returns wrong result 2006-03-05 20:48:31 +04:00
serg@serg.mylan
db896a66ca bad merge fixed 2005-09-15 21:05:42 +02:00
igor@rurik.mysql.com
8c34d8e578 Merge ibabaev@bk-internal.mysql.com:/home/bk/mysql-5.0
into rurik.mysql.com:/home/igor/mysql-5.0
2005-08-22 09:40:10 -07:00
pappa@c-4a09e253.1238-1-64736c10.cust.bredbandsbolaget.se
4084c13605 Merge c-4a09e253.1238-1-64736c10.cust.bredbandsbolaget.se:/home/pappa/mysql-4.1
into  c-4a09e253.1238-1-64736c10.cust.bredbandsbolaget.se:/home/pappa/mysql-5.0
2005-08-20 16:38:55 -04:00
igor@rurik.mysql.com
c4f677feb5 Manual merge 2005-08-19 20:21:09 -07:00
igor@rurik.mysql.com
2d32b77693 distinct.test, distinct.result:
Added test cases for bug #12625.
sql_select.cc:
  Fixed bug #12625.
  Fixed invalid removal of constant items from the DISTINCT
  list in the function create_distinct_group.
2005-08-19 01:57:22 -07:00
monty@mysql.com
15d48525af Merge mysql.com:/home/my/mysql-4.1
into  mysql.com:/home/my/mysql-5.0
2005-07-28 17:09:54 +03:00
monty@mysql.com
3c12d0ae54 Added end marker for tests to make future merges easier 2005-07-28 03:22:47 +03:00
hf@deer.(none)
6c148a7969 Fix for bug #9764 (DISTINCT IFNULL truncates data) 2005-06-08 20:35:37 +05:00
pem@mysql.com
975061bb5a Merge 4.1 to 5.0. 2003-12-16 16:12:28 +01:00
antony@ltantony.rdg.cyberkinetica.homeunix.net
fcf96dbb18 WorkLog#1323
Deprecate the use of TYPE=... Preferred syntax is ENGINE=
2003-12-10 04:31:42 +00:00
pem@mysql.telia.com
6e55a3428a Post-merge fixes. 2003-09-24 15:26:20 +02:00
monty@mashka.mysql.fi
04c43fca8e Optimize thai character handling
Remove sel000xxxx tests
After merge fixes
2003-09-12 04:18:07 +03:00
monty@mashka.mysql.fi
2263e3e51f Merge with 4.0.14 2003-08-11 22:44:43 +03:00
monty@mashka.mysql.fi
d495656ac5 Cleanups 2003-07-09 00:55:07 +03:00
Sinisa@sinisa.nasamreza.org
ee9237e0d8 missing test case for DISTINCT .. LEFT .. 2003-07-05 16:29:11 +03:00
monty@mashka.mysql.fi
34919a03c4 Added thread variable max_seeks_for_key
Change optimizer to prefer key lookups before table scan
Change table scans to be done after tables with constrains on scanned table
2003-06-27 03:04:54 +03:00
monty@mashka.mysql.fi
1f6ecc0cd3 Changed mysql-test to print warnings for not existing table to DROP TABLE
Cleaned up test; Removed wrong DROP TABLE commands and use standard table and database names.
changed store_warning() -> push_warning_print()
2003-01-06 01:48:59 +02:00
monty@hundin.mysql.fi
8830eb4aa9 Change of internal key_field=NULL handling to avoid error messages.
Optimized SELECT DISTINCT ... ORDER BY ... LIMIT
Fixed reference to uninitalized variable
2002-12-03 13:08:25 +02:00
serg@serg.mysql.com
e8c6e2717d bugfix: DISTINCT with const_item in ORDER BY 2002-09-10 19:23:59 +00:00
Sinisa@sinisa.nasamreza.org
63fb2232d2 Change of test case 2002-09-04 14:13:31 +03:00
Sinisa@sinisa.nasamreza.org
265a10ff77 a fix for a bug with all_fields.elements not being changed by
expansion of the wildcards
2002-09-03 23:00:23 +03:00
monty@hundin.mysql.fi
5773b6504a Fixed bug in blocking handling when compiling with OPENSSL (caused hangup in client code)
Fixed bug in SELECT DISTINCT ... ORDER BY not-used-column.
Fixed bug in pthread_mutex_trylock with HPUX 11.0
2002-08-17 00:35:51 +03:00
monty@tik.mysql.fi
9d9bcf25e7 Fix sorting of NULL values (Should always be first)
Fix problem with HAVING and MAX() IS NOT NULL
2002-03-02 09:51:24 +02:00
monty@hundin.mysql.fi
e7575da7bb Portability fixes
Added record_rnd_buffer
Added --safe-user-create
Fix for ALTER TABLE RENAME on windows
2001-08-10 17:37:37 +03:00
monty@donna.mysql.com
ce2260586d Fixed ALTER TABLE on MERGE tables
Fixed bug in DISTINCT
2001-01-28 21:35:50 +02:00
monty@donna.mysql.com
c0f40d14cc Added support for hex strings to mysqlimport
A lot of new tests to mysqltest
Fixed bug with BDB tables and autocommit
2000-12-28 03:56:38 +02:00