mariadb/sql
unknown 585b5bbc92 Fix for BUG#20954: avg(keyval) retuns 0.38 but max(keyval) returns an empty set
The problem was in that opt_sum_query() replaced MIN/MAX functions
with the corresponding constant found in a key, but due to imprecise
representation of float numbers, when evaluating the where clause,
this comparison failed.

When MIN/MAX optimization detects that all tables can be removed,
also remove all conjuncts in a where clause that refer to these
tables. As a result of this fix, these conditions are not evaluated
twice, and in the case of float number comparisons we do not discard
result rows due to imprecise float representation.

As a side-effect this fix also corrects an unnoticed problem in
bug 12882.


mysql-test/r/func_group.result:
  BUG#20954 - test result adjustment.
  Adjusted the test result of bug 12882 which was not preperly fixed.
  The current patch corrects the problem that was fully corrected by the
  patch for 12882.
  
  The problem was that opt_sum_query() indicated that the optimizer may
  remove all tables because all MIN/MAX/COUNT functions are constants,
  but this lead to an empty result instead of NULL because the WHERE
  clause was still evaluated.
  
  The current fix removes all conjuncts in the where clause that
  reference the removed tables, and thus corrects the problem.
mysql-test/r/select.result:
  BUG#20954 - added test
mysql-test/r/subselect.result:
  BUG#20954 - test result adjustment.
  
  The fix removes those conditions in a where clause that refer to
  tables optimized away by MIN/MAX optimization (opt_sum_query()).
mysql-test/t/select.test:
  BUG#20954 - added test
sql/sql_select.cc:
  Fix for BUG#20954: avg(keyval) retuns 0.38 but max(keyval) returns an empty set
  
  When MIN/MAX optimization detects that all tables can be removed,
  also remove all conjuncts in a where clause that refer to these
  tables. As a result of this fix, these conditions are not evaluated
  twice, and in the case of float number comparisons we do not discard
  result rows due to imprecise float representation.
  
  As a side-effect this fix also corrects an unnoticed problem in
  bug 12882.
2006-07-26 01:11:19 +03:00
..
examples Fix for bug #15558: truncate doesn't clear table on archive storage engine tables. 2006-05-18 17:10:58 +05:00
share Fixed bug #17873: confusing error message when IGNORE/USE/FORCE INDEX 2006-05-30 00:08:58 -07:00
.cvsignore
add_errmsg
client_settings.h
custom_conf.h
derror.cc
des_key_file.cc Many files: 2005-09-30 14:03:55 +02:00
discover.cc WL1424 Multiple MySQL Servers: SHOW TABLES etc. should detect new and delete old tables. 2004-09-13 14:46:38 +02:00
field.cc Fixed bug #14896. 2006-06-22 00:29:04 +04:00
field.h A fix and a test case for Bug#13134 "Length of VARCHAR() utf8 2006-02-21 19:52:20 +03:00
field_conv.cc a fix (bug #7589: Decimal types are ignored when updating data from another column). 2005-09-21 14:32:19 +05:00
filesort.cc Review fixes since last pull 2005-09-12 18:48:17 +03:00
frm_crypt.cc
gen_lex_hash.cc Merge with 4.0 2004-09-01 04:12:09 +03:00
gstream.cc
gstream.h
ha_berkeley.cc BUG#6554 Problem Building MySql on Fedora Core 3 2006-01-16 12:17:30 +01:00
ha_berkeley.h BUG#10241 cygwin port: invalid pragma interface directives 2005-05-04 15:05:56 +02:00
ha_blackhole.cc ha_blackhole.cc: 2005-08-30 02:46:03 +02:00
ha_blackhole.h ha_blackhole changes, same patch as http://lists.mysql.com/internals/27878, per brian 2005-08-26 02:09:56 +02:00
ha_heap.cc Cleanup during review of new pushed code 2006-03-30 03:11:37 +03:00
ha_heap.h Bug #12796: Record lost in HEAP table 2005-11-08 00:26:37 -05:00
ha_innodb.cc Applied innodb-4.1-ss29 snapshot. 2006-05-15 17:25:37 +04:00
ha_innodb.h BUG#10241 cygwin port: invalid pragma interface directives 2005-05-04 15:05:56 +02:00
ha_isam.cc a compiler must see '#pragma implementation' *before* 2005-06-05 19:38:52 +02:00
ha_isam.h BUG#10241 cygwin port: invalid pragma interface directives 2005-05-04 15:05:56 +02:00
ha_isammrg.cc a compiler must see '#pragma implementation' *before* 2005-06-05 19:38:52 +02:00
ha_isammrg.h BUG#10241 cygwin port: invalid pragma interface directives 2005-05-04 15:05:56 +02:00
ha_myisam.cc BUG#9622, stage 2, work together with fix for BUG#12232: 2005-10-21 06:29:17 +04:00
ha_myisam.h BUG#10241 cygwin port: invalid pragma interface directives 2005-05-04 15:05:56 +02:00
ha_myisammrg.cc a compiler must see '#pragma implementation' *before* 2005-06-05 19:38:52 +02:00
ha_myisammrg.h Bug#10400 - Improperly-defined MERGE table crashes with INSERT ... ON DUPLICATE KEY UPDATE 2005-05-18 19:40:39 +02:00
ha_ndbcluster.cc Merge poseidon.ndb.mysql.com:/home/tomas/mysql-4.1 2006-06-30 16:26:33 +02:00
ha_ndbcluster.h Fix for Bug #18184 SELECT ... FOR UPDATE does not work..: implemented ha_ndblcuster::unlock_row() and explicitly lock all rows that are not being unlocked 2006-06-08 16:12:38 +02:00
handler.cc Bug #14514 Creating table with packed key fails silently 2005-11-21 12:27:58 +01:00
handler.h Bug #18864 TRUNCATE TABLE doesn't reset AUTO_INCREMENT value on ndb table 2006-06-02 07:26:45 +02:00
hash_filo.cc a compiler must see '#pragma implementation' *before* 2005-06-05 19:38:52 +02:00
hash_filo.h forgotten s/__GNUC__/USE_PRAGMA_INTERFACE/ causes compilation faliures 2005-05-27 14:15:08 +02:00
hostname.cc Fix for bug #15756: incorrect ip address matching in ACL due to use of latin1 collation. 2006-01-24 13:58:28 +04:00
init.cc
item.cc BUG#18492: mysqld reports ER_ILLEGAL_REFERENCE in --ps-protocol 2006-04-28 11:23:31 +02:00
item.h Better comments for void Item::top_level_item() 2006-07-04 13:28:30 +04:00
item_buff.cc group_by.result, group_by.test: 2005-06-21 04:24:21 -07:00
item_cmpfunc.cc BUG#20975: Incorrect query result for NOT (subquery): 2006-07-21 03:04:04 +04:00
item_cmpfunc.h BUG#20975: Incorrect query result for NOT (subquery): 2006-07-21 03:04:04 +04:00
item_create.cc Merging fix for bug #9796 "Query Cache caches queries with CURRENT_USER() 2005-04-11 10:44:48 +04:00
item_create.h Making 4.1 tree compile with -ansi -pedantic 2004-12-16 16:16:28 +03:00
item_func.cc Fix for bug #6880: LAST_INSERT_ID() within a statement 2006-06-07 14:01:10 +05:00
item_func.h Merge april.(none):/home/svoj/devel/mysql/BUG16893/mysql-4.1 2006-02-07 13:49:55 +04:00
item_geofunc.cc Fix for bug #12839 (Endian support is absurd) 2005-09-21 14:35:01 +05:00
item_geofunc.h bug #10166 (Signed byte values cause data to be padded) 2006-06-22 22:11:27 +05:00
item_row.cc A fix and a test case for Bug#16248 "WHERE (col1,col2) IN ((?,?)) 2006-04-07 22:26:25 +04:00
item_row.h A fix and a test case for Bug#16248 "WHERE (col1,col2) IN ((?,?)) 2006-04-07 22:26:25 +04:00
item_strfunc.cc Fixed bug #17526: incorrect print method 2006-07-19 12:36:55 -07:00
item_strfunc.h Fixed bug #17526: incorrect print method 2006-07-19 12:36:55 -07:00
item_subselect.cc BUG#20975: Incorrect query result for NOT (subquery): 2006-07-21 03:04:04 +04:00
item_subselect.h BUG#20975: Incorrect query result for NOT (subquery): 2006-07-21 03:04:04 +04:00
item_sum.cc Fixed bug #20076. 2006-06-22 15:50:15 -07:00
item_sum.h Fixed bug#14169: type of group_concat() result changed to blob if tmp_table was 2006-04-12 23:05:38 +04:00
item_timefunc.cc WL#2928 Date Translation NRE 2006-07-04 17:40:40 +05:00
item_timefunc.h Manually merged 2006-06-17 02:11:12 +04:00
item_uniq.cc a compiler must see '#pragma implementation' *before* 2005-06-05 19:38:52 +02:00
item_uniq.h Add ifdefs to control when "#pragma implementation" should be used 2005-05-26 12:09:14 +02:00
key.cc Merge 2005-03-17 10:59:25 +04:00
lex.h WL#1596 "make mysqldump --master-data --single-transaction able to do online dump of InnoDB AND report reliable 2004-11-10 17:56:45 +01:00
lex_symbol.h
lock.cc Bug#18544 - LOCK TABLES timeout causes MyISAM table corruption 2006-04-19 22:54:25 +05:00
log.cc Fix for BUG#13023: "SQL Thread is up but doesn't move forward". Details in slave.cc; 2005-10-12 13:29:55 +02:00
log_event.cc BUG#16217 fix partly backported from 5.0. It is different in mysqlbinlog part. 2006-02-10 15:12:27 +02:00
log_event.h Fix for BUG#13023: "SQL Thread is up but doesn't move forward". Details in slave.cc; 2005-10-12 13:29:55 +02:00
Makefile.am WL#2928 Date Translation NRE 2006-07-04 17:40:40 +05:00
matherr.c
mf_iocache.cc
my_lock.c
mysql_priv.h BUG#20975: Incorrect query result for NOT (subquery): 2006-07-21 03:04:04 +04:00
mysqld.cc Add comment for 'kill_server' function 2006-05-23 10:33:53 +02:00
mysqld_suffix.h
net_serv.cc Merge selena.:H:/MYSQL/src/#05588-mysql-4.0 2005-09-07 14:59:41 +04:00
nt_servc.cc
nt_servc.h
opt_range.cc Merge spetrunia@bk-internal.mysql.com:/home/bk/mysql-4.1 2006-07-01 01:55:43 +04:00
opt_range.h BUG#12915: Added single-table UPDATE/DELTE ... ORDER BY ... LIMIT 2005-09-30 15:21:37 +04:00
opt_sum.cc Merge april:devel/BitKeeper/mysql-4.1 2006-06-21 17:51:16 +05:00
password.c A fix for Bug#13944 "libmysqlclient exporting sha1_result function": 2006-01-11 17:31:52 +03:00
procedure.cc a compiler must see '#pragma implementation' *before* 2005-06-05 19:38:52 +02:00
procedure.h BUG#10241 cygwin port: invalid pragma interface directives 2005-05-04 15:05:56 +02:00
protocol.cc A fix and a test case for Bug#15613 "libmysqlclient API function 2006-01-18 22:50:31 +03:00
protocol.h BUG#10241 cygwin port: invalid pragma interface directives 2005-05-04 15:05:56 +02:00
protocol_cursor.cc a compiler must see '#pragma implementation' *before* 2005-06-05 19:38:52 +02:00
records.cc Added more tests for new UPDATE ... ORDER BY ... LIMIT optimization 2005-10-25 02:27:40 +03:00
repl_failsafe.cc fix for Valgrind errors: query_id needs to be inited early (already fixed in 5.0 by Konstantin) and so does client_capabilities (not fixed in 5.0); 2005-10-14 15:34:52 +02:00
repl_failsafe.h Merge with 4.0 for 4.1 release 2004-10-06 19:14:33 +03:00
set_var.cc WL#2928 Date Translation NRE 2006-07-04 17:40:40 +05:00
set_var.h WL#2928 Date Translation NRE 2006-07-04 17:40:40 +05:00
slave.cc fix for Valgrind errors: query_id needs to be inited early (already fixed in 5.0 by Konstantin) and so does client_capabilities (not fixed in 5.0); 2005-10-14 15:34:52 +02:00
slave.h Fix for BUG#13023: "SQL Thread is up but doesn't move forward". Details in slave.cc; 2005-10-12 13:29:55 +02:00
spatial.cc Review of new pushed code 2005-11-01 13:00:02 +02:00
spatial.h gcc 4.1 linux warning fixes backported from 5.0. 2006-06-28 16:28:29 +03:00
sql_acl.cc Bug#16372: Server crashes when test 'conc_sys' is running 2006-04-27 14:54:36 +04:00
sql_acl.h Fix for bug #12423 "Deadlock when doing FLUSH PRIVILEGES and GRANT in 2005-09-01 16:52:59 +04:00
sql_analyse.cc Merged code. Removed unneccessary repeating. 2005-09-13 18:11:51 +03:00
sql_analyse.h Add ifdefs to control when "#pragma implementation" should be used 2005-05-26 12:09:14 +02:00
sql_base.cc Fixed bug #17873: confusing error message when IGNORE/USE/FORCE INDEX 2006-05-30 00:08:58 -07:00
sql_bitmap.h terminal.c, sql_bitmap.h, my_sys.h, configure.in, config.h: 2005-05-05 09:15:14 +02:00
sql_cache.cc WL#2928 Date Translation NRE 2006-07-04 17:40:40 +05:00
sql_cache.h Merge sanja.is.com.ua:/home/bell/mysql/bk/work-4.0 2005-09-06 12:18:23 +03:00
sql_class.cc Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-4.1-opt 2006-07-11 17:35:36 +04:00
sql_class.h Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-4.1-opt 2006-07-11 17:35:36 +04:00
sql_client.cc
sql_crypt.cc a compiler must see '#pragma implementation' *before* 2005-06-05 19:38:52 +02:00
sql_crypt.h Add ifdefs to control when "#pragma implementation" should be used 2005-05-26 12:09:14 +02:00
sql_db.cc Bug #15302 LOAD DATA FROM MASTER -> Packets out of order (Found: 2, expected 1) 2006-01-31 12:47:22 +01:00
sql_delete.cc Bug#17137 Running "truncate table" on temporary table leaves the table open on a slave 2006-03-08 10:15:48 +01:00
sql_derived.cc fixed union types merging and table related metadata (BUG#8824) 2005-03-23 08:36:48 +02:00
sql_do.cc Fix for bug #6765 "Implicit access to time zone description 2004-12-09 13:31:46 +03:00
sql_error.cc abort storing query to query cache if warnings appeared (BUG#9414) 2005-06-28 00:52:21 +03:00
sql_handler.cc Re-run fix-fields on condition if table was reopened in HANDLERREAD 2006-01-10 19:13:12 +02:00
sql_help.cc * Added comments and one assert 2004-12-14 03:36:19 +03:00
sql_insert.cc Fix calls to free_underlaid_joins() in INSERT, DELETE, and UPDATE 2005-12-08 12:33:33 -08:00
sql_lex.cc Merge mysql.com:/data0/mysqldev/my/mysql-4.1.20-release 2006-05-26 18:31:25 +02:00
sql_lex.h Fixed bug #14927. 2006-05-06 23:48:13 -07:00
sql_list.cc a compiler must see '#pragma implementation' *before* 2005-06-05 19:38:52 +02:00
sql_list.h merged 2005-05-18 22:14:08 +02:00
sql_load.cc Bug #17154 load data infile of char values into a table of char(PK) hangs 2006-02-07 00:03:39 +01:00
sql_locale.cc WL#2928 Date Translation NRE 2006-07-04 17:40:40 +05:00
sql_manager.cc
sql_manager.h
sql_map.cc a compiler must see '#pragma implementation' *before* 2005-06-05 19:38:52 +02:00
sql_map.h Add ifdefs to control when "#pragma implementation" should be used 2005-05-26 12:09:14 +02:00
sql_olap.cc a compiler must see '#pragma implementation' *before* 2005-06-05 19:38:52 +02:00
sql_parse.cc BUG#20975: Incorrect query result for NOT (subquery): 2006-07-21 03:04:04 +04:00
sql_prepare.cc Fixed bug #14927. 2006-05-06 23:48:13 -07:00
sql_rename.cc Bug#6391 (binlog-do-db rules ignored) 2004-12-03 12:13:51 +01:00
sql_repl.cc Fix for BUG#12003 "assertion failure in testsuite (double lock of 2005-07-18 14:46:53 +02:00
sql_repl.h Remove DUP_IGNORE from enum_duplicates and instead use a separate ignore flag 2004-12-31 12:04:35 +02:00
sql_select.cc Fix for BUG#20954: avg(keyval) retuns 0.38 but max(keyval) returns an empty set 2006-07-26 01:11:19 +03:00
sql_select.h gcc 4.1 linux warning fixes backported from 5.0. 2006-06-28 16:28:29 +03:00
sql_show.cc Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-4.1 2006-05-04 13:17:16 +03:00
sql_sort.h
sql_state.c
sql_string.cc Bug#15375 Unassigned multibyte codes are broken 2005-12-12 21:42:09 +04:00
sql_string.h BUG#10241 cygwin port: invalid pragma interface directives 2005-05-04 15:05:56 +02:00
sql_table.cc Merge bk@192.168.21.1:mysql-4.1 2006-05-04 00:03:58 +05:00
sql_test.cc Bug#12920 - key_read_requests counter appears to re-set 2005-09-14 13:18:16 +02:00
sql_udf.cc - backport of a compile fix from 4.1 (ChangeSet@1.2260.23.2 2005/05/19 from reggie) 2005-06-30 17:33:23 +02:00
sql_udf.h Merge bk-internal.mysql.com:/home/bk/mysql-4.1 2005-05-09 12:16:59 +02:00
sql_union.cc Fixed bug #18767. 2006-04-20 22:15:38 -07:00
sql_update.cc gcc 4.1 linux warning fixes backported from 5.0. 2006-06-28 16:28:29 +03:00
sql_yacc.yy Fixed bug #18767. 2006-04-20 22:15:38 -07:00
stacktrace.c Step 2 of the switch to support configuration with NPTL: 2005-04-20 20:38:57 +02:00
stacktrace.h Step 2 of the switch to support configuration with NPTL: 2005-04-20 20:38:57 +02:00
strfunc.cc - Housekeeping: removed a few unreferenced variables, noticed while doing 2005-01-11 15:38:03 +01:00
structs.h Better comments in KEY_PART_INFO struct 2006-06-14 21:06:02 +04:00
table.cc Reverted wrong bug fix (Bug#11228) 2006-06-30 18:29:27 +03:00
table.h Merge mysql.com:/home/mydev/mysql-4.0-bug5390 2006-01-23 19:19:29 +01:00
thr_malloc.cc Simpler arena swapping code 2004-11-08 01:13:54 +02:00
time.cc Bug#20729: Bad date_format() call makes mysql server crash 2006-07-11 13:06:29 -04:00
tzfile.h WL#1264 "Per-thread time zone support infrastructure". 2004-06-18 10:11:31 +04:00
tztime.cc Minor Netware specific changes. 2005-12-13 18:30:10 +02:00
tztime.h BUG#10241 cygwin port: invalid pragma interface directives 2005-05-04 15:05:56 +02:00
udf_example.cc Ensure that we free memory used with --order-by-primary (in mysqldump) 2004-12-09 12:47:20 +02:00
uniques.cc
unireg.cc Review of new code: 2005-07-27 13:05:30 +03:00
unireg.h Fixed bug#14169: type of group_concat() result changed to blob if tmp_table was 2006-04-12 23:05:38 +04:00
watchdog_mysqld