mariadb/mysql-test/include
unknown 7bb6a72593 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.


sql/item.cc:
  Bug#27590: Wrong 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.
sql/item.h:
  Bug#27590: Wrong 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.
sql/item_cmpfunc.cc:
  Bug#27590: Wrong DATE/DATETIME comparison.
  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.
sql/item_cmpfunc.h:
  Bug#27590: Wrong DATE/DATETIME comparison.
  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.
mysql-test/include/ps_conv.inc:
  Test case adjusted after fix for bug#27590.
mysql-test/r/distinct.result:
  Test cases results are corrected after fix for bug#27590.
sql/sql_select.cc:
  Bug#27590: Wrong DATE/DATETIME comparison.
  The test_if_equality_guarantees_uniqueness() function now uses
  Arg_comparator::can_compare_as_dates() to detect comparable DATE/DATETIME items.
mysql-test/r/ps_2myisam.result:
  The result of the adjusted test case after fix for bug#27590.
mysql-test/r/ps_3innodb.result:
  The result of the adjusted test case after fix for bug#27590.
mysql-test/r/ps_4heap.result:
  The result of the adjusted test case after fix for bug#27590.
mysql-test/r/ps_5merge.result:
  The result of the adjusted test case after fix for bug#27590.
mysql-test/r/subselect.result:
  Test cases results are corrected after fix for bug#27590.
mysql-test/r/type_datetime.result:
  Added a test case for the bug#27590: Wrong DATE/DATETIME comparison.
mysql-test/t/type_datetime.test:
  Added a test case for the bug#27590: Wrong DATE/DATETIME comparison.
tests/mysql_client_test.c:
  Test case adjusted after fix for bug#27590.
2007-04-27 00:12:09 +04:00
..
add_anonymous_users.inc Bug#20166 mysql-test-run.pl does not test system privilege tables creation 2007-02-26 11:49:24 +01:00
analyze_failure_sync_with_master.test Add analyze_testcase_failure which is called when mysqltest has failed 2006-10-24 17:36:46 +02:00
big_test.inc Moved some old test and added a new test to only be run with mysql-test-run --big 2005-04-07 19:24:14 +03:00
check-testcase.test Print names of testcases that failed check_testcase, this makes it easier 2006-10-08 17:48:01 +02:00
check_var_limit.inc Add detection of in_addr_t 2003-08-28 06:08:17 +03:00
common-tests.inc Post-merge fixes 2006-05-31 22:55:45 -07:00
ctype_common.inc Privileges columns were removed from output to be able 2004-12-10 17:58:13 +04:00
ctype_filesort.inc bug#7284: strnxfrm returns different results for equal strings 2005-01-13 18:12:04 +04:00
ctype_innodb_like.inc ctype_innodb_like.inc: 2005-07-06 17:16:22 +05:00
ctype_like_escape.inc Add printout of file in which warning was detected 2006-10-06 00:57:10 +02:00
delete_anonymous_users.inc Bug#20166 mysql-test-run.pl does not test system privilege tables creation 2007-02-26 11:49:24 +01:00
endspace.inc Move common trailing space checks into an include file. 2004-12-01 19:25:05 +04:00
federated.inc Merge bk@192.168.21.1:mysql-5.0-opt 2006-12-08 15:22:46 +04:00
federated_cleanup.inc This is the same patch as 1.1937, with small variable declaration changes, memory 2005-07-15 17:33:47 -07:00
get_binlog_dump_thread_id.inc Workaround non portable use of "grep" and "cut" by loading the whole processlist 2007-02-26 09:16:22 +01:00
gis_generic.inc gis_generic test cases: 2007-03-29 11:20:08 +02:00
have_archive.inc Add DROP TABLE before trying to create view (in mysqldump) 2005-10-27 22:45:18 +03:00
have_bdb.inc changes to make things work in the max version 2001-10-04 15:42:25 -06:00
have_big5.inc "like" did not work in some cases with character set big5 2003-12-24 16:59:48 +04:00
have_blackhole.inc Additional storage engine called "blackhole". Customer request, and for that matter a Zawodny request. With this you can alter table to a type of table that would never store data. Its a /dev/null for a database. 2005-03-22 16:10:39 -08:00
have_case_sensitive_file_system.inc Bugs#17647: Trouble with "create database" 2006-05-04 11:55:09 +05:00
have_compress.inc added compress/uncompress function 2003-04-09 20:50:30 -04:00
have_cp932.inc Added cp932 character set 2005-05-05 10:36:17 -07:00
have_cp1250_ch.inc Bug#8840 Empty string comparison and character set 'cp1250' 2005-03-03 14:15:37 +04:00
have_crypt.inc Fixes for Netware 2003-01-28 08:38:28 +02:00
have_csv.inc This is the addition of the CSV engine "aka tina". Its an example engine that works as a plain text file. 2004-08-12 20:57:18 -07:00
have_debug.inc Robustness feature. 2004-06-20 19:11:02 +02:00
have_eucjpms.inc Skip cp932 and eucjpms tests when the character sets are not compiled. 2005-02-01 14:37:51 +04:00
have_euckr.inc Bug#15377 Valid multibyte sequences are truncated on INSERT 2005-12-09 16:37:58 +04:00
have_exampledb.inc Adding test cases for the example storage engine (so that you can test to see if it was built correctly). 2004-08-13 17:14:36 -07:00
have_federated_db.inc -Added quote_data and needs_quotes (moved from federated handler. 2005-01-20 18:36:40 -08:00
have_gb2312.inc Bug#15377 Valid multibyte sequences are truncated on INSERT 2005-12-09 16:37:58 +04:00
have_gbk.inc ctype-gbk.c: 2005-07-22 21:06:02 +05:00
have_geometry.inc Add DROP TABLE before trying to create view (in mysqldump) 2005-10-27 22:45:18 +03:00
have_innodb.inc changes to make things work in the max version 2001-10-04 15:42:25 -06:00
have_latin2_ch.inc Bug#17374: select ... like 'A%' operator fails to find value on columuns with key 2006-03-20 16:28:25 +04:00
have_lowercase0.inc Backport test cases fixes from 5.0 2006-10-19 10:54:23 +02:00
have_multi_ndb.inc Update mysqltest to latest version 2006-10-03 15:33:44 +02:00
have_ndb.inc Set the environment variable NDB_STATUS_OK to indicate that cluster is installed ok. This is actually not needed for this script as it will 2006-10-05 12:28:23 +02:00
have_outfile.inc Make it possible to run mysql-test-run.pl with default test suite in different vardir. 2006-01-24 08:30:54 +01:00
have_query_cache.inc A lot of fixes for prepared statements (PS): 2004-10-26 19:30:01 +03:00
have_sjis.inc #3290: Can't convert sjis&ujis half-width katakana correctly 2004-03-25 14:29:56 +04:00
have_ssl.inc Add "have_ssl" as synonym for "have_openssl" 2007-03-05 10:03:42 +01:00
have_tis620.inc Bug 1552: 2003-12-25 20:11:01 +04:00
have_ucs2.inc Character set sets now check if required non-dynamic charsets were really compiled 2003-05-23 15:10:05 +05:00
have_udf.inc Add test to mysql-test-run.pl to see if the udf_example.so is availble. Set envioronment variable UDF_EXAMPLE_LIB if it is. 2006-04-27 16:32:40 +02:00
have_ujis.inc Character set sets now check if required non-dynamic charsets were really compiled 2003-05-23 15:10:05 +05:00
im_check_env.inc Preliminary patch for the following bugs: 2006-08-29 15:46:40 +04:00
innodb_rollback_on_timeout.inc Added innodb_rollback_on_timeout option to restore the 4.1 2006-12-19 16:57:51 -07:00
is_debug_build.inc Post-review fixes, mainly fixing all print() methods for sp_instr* classes. 2005-11-18 16:30:27 +01:00
loaddata_autocom.inc Fix for BUG#11151 "LOAD DATA INFILE commits transaction in 5.0". 2006-09-05 16:52:05 +02:00
master-slave.inc Update mysqltest to latest version 2006-10-03 15:33:44 +02:00
mysqltest-x.inc Bug#12959 mysqltest crashes if testcase passed with -x option 2005-09-05 16:50:32 +02:00
ndb_backup.inc Bug#26899 ndb_restore cannot restore selected tables and databases 2007-03-07 13:19:37 +07:00
ndb_backup_print.inc Bug#26899 ndb_restore cannot restore selected tables and databases 2007-03-07 13:19:37 +07:00
ndb_default_cluster.inc Bug #20820 auto inc table not handled correctly when restored from cluster backup 2006-07-06 18:50:44 +02:00
not_as_root.inc Use "eval select" when evaluating the environment variable "$MYSQL_TEST_ROOT" 2006-04-24 12:01:16 +02:00
not_embedded.inc After merge fixes 2003-05-21 21:39:58 +03:00
not_openssl.inc BUG#10589: des_encrypt functionality always return NULL 2005-06-17 18:07:46 +02:00
not_windows.inc Skip two tests that fail on Windows that just reflect limitations of 2005-08-03 17:38:55 -07:00
ps_conv.inc Bug#27590: Wrong DATE/DATETIME comparison. 2007-04-27 00:12:09 +04:00
ps_create.inc bug#10466: Datatype "timestamp" displays "YYYYMMDDHHMMSS" irrespective of display sizes. 2005-06-20 12:09:00 +02:00
ps_modify.inc Patch two (the final one) for Bug#7306 "the server side preparedStatement 2005-06-07 14:11:36 +04:00
ps_modify1.inc Small bug fix 2004-12-13 21:00:43 +01:00
ps_query.inc Update mysqltest to latest version 2006-10-03 15:33:44 +02:00
ps_renew.inc Results of WL#1856 "Conversion of client_test.c tests cases to mysqltest 2004-09-25 19:08:02 +04:00
report-features.test add --report-features to mysql-test-run.pl 2006-11-10 13:12:08 +01:00
rpl_stmt_seq.inc Fix of 5.0 tree 2005-06-17 14:03:27 +02:00
show_msg.inc Update mysqltest to latest version 2006-10-03 15:33:44 +02:00
show_msg80.inc Update mysqltest to latest version 2006-10-03 15:33:44 +02:00
sp-vars.inc Remove compiler warnings 2006-11-20 22:42:06 +02:00
strict_autoinc.inc Bug#18908: ERROR 1406 (22001): Data too long for column :: using utf8 2006-10-30 10:14:03 +04:00
system_db_struct.inc Add all SQL_MODE settings to proc table. (Bug #8902) 2005-03-08 17:40:43 -08:00
test_outfile.inc Make it possible to run mysql-test-run.pl with default test suite in different vardir. 2006-01-24 08:30:54 +01:00
testdb_only.inc WL#1420 convert NIST test for mysql 2005-01-26 10:19:28 +01:00
varchar.inc Fix bug #10802 Index is not used if table using BDB engine on HP-UX 2005-08-15 13:02:29 +04:00
wait_for_query_to_suceed.inc Bug#18654 Test is timing-dependent and fails from scheduling effects (?) 2006-10-30 14:42:28 +01:00
wait_show_pattern.inc Fix for bug #25044 "ALTER TABLE ... ENABLE KEYS acquires global 'opening 2007-01-19 23:15:59 +03:00
wait_slave_status.inc Fix for bug #25044 "ALTER TABLE ... ENABLE KEYS acquires global 'opening 2007-01-19 23:15:59 +03:00
windows.inc Fix handling of filenames that start the same as reserved filenames 2005-08-31 18:32:15 -07:00