summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorRamil Kalimullin <ramil@mysql.com>2008-09-09 20:52:38 +0500
committerRamil Kalimullin <ramil@mysql.com>2008-09-09 20:52:38 +0500
commiteb2794d4224d845a74a898fb46dd1bf487680cac (patch)
treee389f8e0eb61769806307b940aa775ea2db4f8ea /sql/item_cmpfunc.cc
parentac1bcc20d1b5805bf2a66316d755e553289a8364 (diff)
parent776793a97c97c4e2b2c7a6a2870696c147eb235c (diff)
downloadmariadb-git-eb2794d4224d845a74a898fb46dd1bf487680cac.tar.gz
Merge
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc20
1 files changed, 13 insertions, 7 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index dec07a587a5..bd6065c9403 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -1029,19 +1029,24 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
1 if items are equal or both are null
0 otherwise
If is_nulls_eq is FALSE:
- -1 a < b or one of items is null
+ -1 a < b or at least one item is null
0 a == b
1 a > b
+ See the table:
+ is_nulls_eq | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
+ a_is_null | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 |
+ b_is_null | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 |
+ result | 1 | 0 | 0 |0/1|-1 |-1 |-1 |-1/0/1|
*/
int Arg_comparator::compare_datetime()
{
- bool is_null= FALSE;
+ bool a_is_null, b_is_null;
ulonglong a_value, b_value;
/* Get DATE/DATETIME/TIME value of the 'a' item. */
- a_value= (*get_value_func)(thd, &a, &a_cache, *b, &is_null);
- if (!is_nulls_eq && is_null)
+ a_value= (*get_value_func)(thd, &a, &a_cache, *b, &a_is_null);
+ if (!is_nulls_eq && a_is_null)
{
if (owner)
owner->null_value= 1;
@@ -1049,14 +1054,15 @@ int Arg_comparator::compare_datetime()
}
/* Get DATE/DATETIME/TIME value of the 'b' item. */
- b_value= (*get_value_func)(thd, &b, &b_cache, *a, &is_null);
- if (is_null)
+ b_value= (*get_value_func)(thd, &b, &b_cache, *a, &b_is_null);
+ if (a_is_null || b_is_null)
{
if (owner)
owner->null_value= is_nulls_eq ? 0 : 1;
- return is_nulls_eq ? 1 : -1;
+ return is_nulls_eq ? (a_is_null == b_is_null) : -1;
}
+ /* Here we have two not-NULL values. */
if (owner)
owner->null_value= 0;