mariadb/sql
evgen@moonbone.local 4747fa0c03 Bug#27590: Wrong DATE/DATETIME comparison.
DATE and DATETIME can be compared either as strings or as int. Both
methods have their disadvantages. Strings can contain valid DATETIME value
but have insignificant zeros omitted thus became non-comparable with
other DATETIME strings. The comparison as int usually will require conversion
from the string representation and the automatic conversion in most cases is
carried out in a wrong way thus producing wrong comparison result. Another
problem occurs when one tries to compare DATE field with a DATETIME constant.
The constant is converted to DATE losing its precision i.e. losing time part.

This fix addresses the problems described above by adding a special
DATE/DATETIME comparator. The comparator correctly converts DATE/DATETIME
string values to int when it's necessary, adds zero time part (00:00:00)
to DATE values to compare them correctly to DATETIME values. Due to correct
conversion malformed DATETIME string values are correctly compared to other
DATE/DATETIME values.

As of this patch a DATE value equals to DATETIME value with zero time part.
For example '2001-01-01' equals to '2001-01-01 00:00:00'.

The compare_datetime() function is added to the Arg_comparator class.
It implements the correct comparator for DATE/DATETIME values.
Two supplementary functions called get_date_from_str() and get_datetime_value()
are added. The first one extracts DATE/DATETIME value from a string and the
second one retrieves the correct DATE/DATETIME value from an item.
The new Arg_comparator::can_compare_as_dates() function is added and used
to check whether two given items can be compared by the compare_datetime()
comparator.
Two caching variables were added to the Arg_comparator class to speedup the
DATE/DATETIME comparison.
One more store() method was added to the Item_cache_int class to cache int
values.
The new is_datetime() function was added to the Item class. It indicates
whether the item returns a DATE/DATETIME value.
2007-04-27 00:12:09 +04:00
..
examples BUG#26138 - REPAIR TABLE with option USE_FRM erases all records in 2007-03-30 13:00:21 +05:00
share Bug#24617 Typo in Czech translation 2007-02-22 17:53:41 +01:00
.cvsignore
add_errmsg
client_settings.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
CMakeLists.txt Merge mjorgensen@bk-internal.mysql.com:/home/bk/mysql-5.0-sage 2007-01-11 09:19:32 +01:00
custom_conf.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
derror.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
des_key_file.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
discover.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
field.cc Merge bk@192.168.21.1:mysql-5.0 2007-04-07 11:36:02 +05:00
field.h Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.0 2007-04-02 10:50:39 +02:00
field_conv.cc Bug#23233: 0 as LAST_INSERT_ID() after INSERT .. ON DUPLICATE in the 2007-03-30 18:13:33 +04:00
filesort.cc Bug #26672: 2007-03-07 14:51:45 +02:00
frm_crypt.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
gen_lex_hash.cc gen_lex_hash.cc: 2007-01-31 00:06:42 +01:00
gstream.cc Many files: 2006-12-23 20:17:15 +01:00
gstream.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
ha_archive.cc BUG#26138 - REPAIR TABLE with option USE_FRM erases all records in 2007-03-30 13:00:21 +05:00
ha_archive.h Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-01-22 14:04:40 +02:00
ha_berkeley.cc Fixed compiler warnings. 2007-02-28 22:23:35 +02:00
ha_berkeley.h Fixed compiler warnings (for linux and win32 and win64) 2007-02-22 16:59:57 +02:00
ha_blackhole.cc Bug#19717: The blackhole engine is returning an OK flag in 2007-02-14 18:35:59 +02:00
ha_blackhole.h Many files: 2006-12-23 20:17:15 +01:00
ha_federated.cc Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-01-22 14:04:40 +02:00
ha_federated.h Many files: 2006-12-23 20:17:15 +01:00
ha_heap.cc Merge chilla.local:/home/mydev/mysql-4.1-bug24985 2007-03-27 10:54:37 +02:00
ha_heap.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
ha_innodb.cc NULL MERGE this to 5.1 2007-03-22 14:40:52 -06:00
ha_innodb.h Applied innodb-5.0-ss1230 snapshot 2007-01-21 17:58:02 -07:00
ha_myisam.cc Merge bk-internal.mysql.com:/home/bk/mysql-5.0-engines 2007-03-25 14:44:16 +02:00
ha_myisam.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
ha_myisammrg.cc Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-02-21 14:07:08 +02:00
ha_myisammrg.h Merge chilla.local:/home/mydev/mysql-4.1-bug26464 2007-03-06 10:34:14 +01:00
ha_ndbcluster.cc Merge mskold@bk-internal.mysql.com:/home/bk/mysql-5.0-ndb 2007-04-05 09:18:37 +02:00
ha_ndbcluster.h Merge mysql.com:/windows/Linux_space/MySQL/mysql-5.0 2007-04-05 08:39:12 +02:00
handler.cc Merge dev3-240.dev.cn.tlan:/home/justin.he/mysql/mysql-5.0/mysql-5.0-ndb 2007-04-05 11:30:19 +08:00
handler.h BUG#26138 - REPAIR TABLE with option USE_FRM erases all records in 2007-03-30 13:00:21 +05:00
hash_filo.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
hash_filo.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
hostname.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
init.cc Merge mysql.com:/home/ram/work/b19690/b19690.4.1 2007-01-31 10:07:56 +04:00
item.cc Bug#27590: Wrong DATE/DATETIME comparison. 2007-04-27 00:12:09 +04:00
item.h Bug#27590: Wrong DATE/DATETIME comparison. 2007-04-27 00:12:09 +04:00
item_buff.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
item_cmpfunc.cc Bug#27590: Wrong DATE/DATETIME comparison. 2007-04-27 00:12:09 +04:00
item_cmpfunc.h Bug#27590: Wrong DATE/DATETIME comparison. 2007-04-27 00:12:09 +04:00
item_create.cc Many files: 2006-12-23 20:17:15 +01:00
item_create.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
item_func.cc Merge kboortz@bk-internal.mysql.com:/home/bk/mysql-5.0 2007-04-08 20:46:40 +02:00
item_func.h Merge acurtis@bk-internal:/home/bk/mysql-5.0-engines 2007-04-06 18:07:02 +00:00
item_geofunc.cc Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-5.0-maint 2007-03-05 18:22:35 +04:00
item_geofunc.h Merge mysql.com:/home/ram/work/b26038/b26038.4.1 2007-02-28 12:13:46 +04:00
item_row.cc Many files: 2006-12-23 20:17:15 +01:00
item_row.h Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-01-22 14:04:40 +02:00
item_strfunc.cc Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.0 2007-04-02 10:50:39 +02:00
item_strfunc.h Bug #26537: item_unhex() was not expected 2007-03-02 12:14:50 +02:00
item_subselect.cc Polishing: use constants instead of magic numbers. 2007-03-09 08:05:08 +03:00
item_subselect.h Merge weblab.(none):/home/marcsql/TREE/mysql-5.0-base 2007-03-01 14:06:57 -07:00
item_sum.cc Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.0 2007-04-02 10:50:39 +02:00
item_sum.h Fixed bug #27229: crash when a set function aggregated in outer 2007-03-22 14:48:03 -07:00
item_timefunc.cc Fixed compiler warnings (for linux and win32 and win64) 2007-02-22 16:59:57 +02:00
item_timefunc.h bug #16546 (DATETIME+0 not always coerced the same way) 2007-03-22 12:44:38 +04:00
item_uniq.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
item_uniq.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
key.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
lex.h Fix -ansi -pedantic warning (can't cast a pointer to function 2007-03-08 12:04:45 +03:00
lex_symbol.h Fix -ansi -pedantic warning (can't cast a pointer to function 2007-03-08 12:04:45 +03:00
lock.cc - renaming TMP_TABLE to NON_TRANSACTIONAL_TMP_TABLE because this is 2007-03-22 15:07:32 +01:00
log.cc Fix warning on Windows 2007-03-28 19:49:30 -06:00
log_event.cc Bug#26837 Return value ignored for packet->append() call within Log_event::read_log_event 2007-03-23 19:00:34 +01:00
log_event.h Merge abarkov@bk-internal.mysql.com:/home/bk/mysql-5.0-rpl 2007-02-28 17:17:06 +04:00
Makefile.am Merge neptunus.(none):/home/msvensson/mysql/bug10777/my50-bug10777 2007-02-15 15:05:25 +01:00
matherr.c my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
message.mc make dist changes for Cmake build 2006-09-01 10:32:12 +02:00
mf_iocache.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
my_decimal.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
my_decimal.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
my_lock.c my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
mysql_priv.h Merge mysql.com:/windows/Linux_space/MySQL/mysql-5.0 2007-04-05 08:39:12 +02:00
mysqld.cc Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.0-rpl 2007-03-31 00:15:20 +02:00
mysqld_suffix.h Many files: 2006-12-23 20:17:15 +01:00
net_serv.cc Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-02-21 14:07:08 +02:00
nt_servc.cc
nt_servc.h
opt_range.cc BUG#26624, pushbuild fixes: Merge to 5.0 2007-03-31 00:48:31 +04:00
opt_range.h Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-01-22 14:04:40 +02:00
opt_sum.cc Merge olga.mysql.com:/home/igor/dev-opt/mysql-4.1-opt-bug24987 2007-01-30 13:14:52 -08:00
parse_file.cc Polishing: add comments. 2007-04-06 18:56:39 +04:00
parse_file.h Many files: 2006-12-23 20:17:15 +01:00
password.c Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-01-22 14:04:40 +02:00
procedure.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
procedure.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
protocol.cc Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-01-22 14:04:40 +02:00
protocol.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
records.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
repl_failsafe.cc Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-02-21 14:07:08 +02:00
repl_failsafe.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
set_var.cc Merge pilot.blaudden:/home/msvensson/mysql/bug21781/my50-bug21781 2007-03-05 11:50:59 +01:00
set_var.h Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-02-21 14:07:08 +02:00
slave.cc Merge polly.local:/tmp/maint/bug23775/my50-bug23775 2007-03-20 17:27:49 +03:00
slave.h Fix for BUG#24432 2007-02-08 15:53:14 +01:00
sp.cc Bug#23491 MySQLDump prefix function call in a view by database name 2007-03-27 12:31:44 -04:00
sp.h Many files: 2006-12-23 20:17:15 +01:00
sp_cache.cc Many files: 2006-12-23 20:17:15 +01:00
sp_cache.h Many files: 2006-12-23 20:17:15 +01:00
sp_head.cc Polishing: note added. 2007-04-06 20:21:30 +04:00
sp_head.h Merge bk-internal.mysql.com:/home/bk/mysql-5.0-maint 2007-03-29 12:20:13 -04:00
sp_pcontext.cc Bug#26503 (Illegal SQL exception handler code causes the server to crash) 2007-03-14 12:02:32 -06:00
sp_pcontext.h Bug#26503 (Illegal SQL exception handler code causes the server to crash) 2007-03-14 12:02:32 -06:00
sp_rcontext.cc Many files: 2006-12-23 20:17:15 +01:00
sp_rcontext.h Many files: 2006-12-23 20:17:15 +01:00
spatial.cc Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-5.0-maint 2007-03-05 18:22:35 +04:00
spatial.h Bug #24563: MBROverlaps does not seem to function propertly. 2007-03-23 16:28:07 -06:00
sql_acl.cc Bug#26285 selecting information_schema crahes server 2007-03-16 12:15:51 +04:00
sql_acl.h Bug#20166 mysql-test-run.pl does not test system privilege tables creation 2007-03-16 20:56:16 +01:00
sql_analyse.cc Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-5.0-maint 2007-02-06 17:18:43 +04:00
sql_analyse.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_array.h Many files: 2006-12-23 20:17:15 +01:00
sql_base.cc Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.0-rpl 2007-03-31 12:36:50 +02:00
sql_bitmap.h Many files: 2006-12-23 20:17:15 +01:00
sql_cache.cc Merge moonlight.home:/home/tomash/src/mysql_ab/mysql-5.0 2007-01-25 20:10:40 +03:00
sql_cache.h Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-01-22 14:04:40 +02:00
sql_class.cc Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.0-rpl 2007-03-29 12:25:28 +02:00
sql_class.h Fixed bug #27229: crash when a set function aggregated in outer 2007-03-22 14:48:03 -07:00
sql_client.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_crypt.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_crypt.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_cursor.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_cursor.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_db.cc Many files: 2006-12-23 20:17:15 +01:00
sql_delete.cc Merge mysql.com:/windows/Linux_space/MySQL/mysql-5.0 2007-04-05 08:39:12 +02:00
sql_derived.cc - renaming TMP_TABLE to NON_TRANSACTIONAL_TMP_TABLE because this is 2007-03-22 15:07:32 +01:00
sql_do.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_error.cc Many files: 2006-12-23 20:17:15 +01:00
sql_error.h Many files: 2006-12-23 20:17:15 +01:00
sql_handler.cc Many files: 2006-12-23 20:17:15 +01:00
sql_help.cc Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving. 2007-02-19 14:39:37 +02:00
sql_insert.cc Merge mysql.com:/windows/Linux_space/MySQL/mysql-5.0 2007-04-05 08:39:12 +02:00
sql_lex.cc Merge bk@192.168.21.1:mysql-5.0 2007-03-08 21:42:41 +04:00
sql_lex.h Merge bk@192.168.21.1:mysql-5.0 2007-03-08 21:42:41 +04:00
sql_list.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_list.h Merge of BUG#26624 and BUG#26625 2007-03-29 10:35:28 +04:00
sql_load.cc Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt 2007-04-07 23:09:09 +04:00
sql_locale.cc Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.0-rpl 2007-01-12 12:22:54 +01:00
sql_manager.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_manager.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_map.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_map.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_olap.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_parse.cc Merge bk@192.168.21.1:mysql-5.0 2007-03-16 11:55:16 +04:00
sql_prepare.cc Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt 2007-03-16 10:50:33 +02:00
sql_rename.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_repl.cc Removing two more compilation warnings. 2007-03-01 10:40:48 +01:00
sql_repl.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_select.cc Bug#27590: Wrong DATE/DATETIME comparison. 2007-04-27 00:12:09 +04:00
sql_select.h Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt 2007-03-22 18:49:47 +02:00
sql_show.cc Merge zippy.cornsilk.net:/home/cmiller/work/mysql/bug27047/my50-prece-bug27047 2007-03-27 11:34:16 -04:00
sql_sort.h Many files: 2006-12-23 20:17:15 +01:00
sql_state.c Many files: 2006-12-23 20:17:15 +01:00
sql_string.cc Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-01-22 14:04:40 +02:00
sql_string.h Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-01-22 14:04:40 +02:00
sql_table.cc Merge sgluhov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt 2007-04-10 15:02:04 +05:00
sql_test.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_trigger.cc A fix for Bug#26750 "valgrind leak in sp_head" (and post-review 2007-03-07 12:24:46 +03:00
sql_trigger.h Merge mysql.com:/windows/Linux_space/MySQL/mysql-5.0 2007-04-05 08:39:12 +02:00
sql_udf.cc Merge bk-internal:/home/bk/mysql-5.0-opt 2007-01-03 18:29:39 +02:00
sql_udf.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_union.cc Bug#22331: Wrong WHERE in EXPLAIN EXTENDED when all expressions were optimized 2007-03-10 00:29:02 +03:00
sql_update.cc Merge mysql.com:/windows/Linux_space/MySQL/mysql-5.0 2007-04-05 08:39:12 +02:00
sql_view.cc sql_view.cc: 2007-03-22 23:13:40 +03:00
sql_view.h Many files: 2006-12-23 20:17:15 +01:00
sql_yacc.yy Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.0 2007-04-02 10:50:39 +02:00
stacktrace.c Many files: 2006-12-23 20:17:15 +01:00
stacktrace.h Many files: 2006-12-23 20:17:15 +01:00
strfunc.cc Many files: 2006-12-23 20:17:15 +01:00
structs.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
table.cc Merge pilot.blaudden:/home/msvensson/mysql/mysql-4.1-maint 2007-04-02 10:42:08 +02:00
table.h Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.0-rpl 2007-03-31 12:36:50 +02:00
thr_malloc.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
time.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
tzfile.h Many files: 2006-12-23 20:17:15 +01:00
tztime.cc Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.0 2007-03-01 18:12:56 +01:00
tztime.h Many files: 2006-12-23 20:17:15 +01:00
udf_example.c Many files: 2006-12-23 20:17:15 +01:00
udf_example.def Fixed compiler warnings (for linux and win32 and win64) 2007-02-22 16:59:57 +02:00
uniques.cc Many files: 2006-12-23 20:17:15 +01:00
unireg.cc Fixed compiler warnings (for linux and win32 and win64) 2007-02-22 16:59:57 +02:00
unireg.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
watchdog_mysqld