summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2002-05-07 19:08:56 +0300
committerunknown <monty@hundin.mysql.fi>2002-05-07 19:08:56 +0300
commitdaafa8db5049da5a8e3c51edb7cb5b7f36dbc73f (patch)
tree998601644441d26cc8a548d4f2e086978a15feea /sql
parent6c6ae10e7532e3630396160ccb41f79ce8ce001c (diff)
downloadmariadb-git-daafa8db5049da5a8e3c51edb7cb5b7f36dbc73f.tar.gz
Fix for ISNULL()
Docs/manual.texi: Chagnelog mysql-test/r/join.result: New tests for IS NULL mysql-test/t/join.test: New tests for IS NULL
Diffstat (limited to 'sql')
-rw-r--r--sql/item_cmpfunc.cc2
-rw-r--r--sql/item_cmpfunc.h7
-rw-r--r--sql/item_timefunc.h2
3 files changed, 9 insertions, 2 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 0c0eef37841..73821f8d826 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -1211,7 +1211,7 @@ longlong Item_func_isnull::val_int()
This has to be here because of the test in update_used_tables().
*/
if (!used_tables_cache)
- return 0;
+ return cached_value;
(void) args[0]->val();
return (args[0]->null_value) ? 1 : 0;
}
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 5ee0687c064..e7c598808e8 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -429,6 +429,7 @@ class Item_func_in :public Item_int_func
class Item_func_isnull :public Item_bool_func
{
+ longlong cached_value;
public:
Item_func_isnull(Item *a) :Item_bool_func(a) {}
longlong val_int();
@@ -449,6 +450,12 @@ public:
args[0]->update_used_tables();
used_tables_cache=args[0]->used_tables();
}
+ if (!used_tables_cache)
+ {
+ /* Remember if the value is always NULL or never NULL */
+ args[0]->val();
+ cached_value= args[0]->null_value ? (longlong) 1 : (longlong) 0;
+ }
}
optimize_type select_optimize() const { return OPTIMIZE_NULL; }
};
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index 6913d4c6809..720f8ba2882 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -47,7 +47,7 @@ public:
Item_func_to_days(Item *a) :Item_int_func(a) {}
longlong val_int();
const char *func_name() const { return "to_days"; }
- void fix_length_and_dec() { decimals=0; max_length=6; }
+ void fix_length_and_dec() { decimals=0; max_length=6; maybe_null=1; }
};