summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <igor@olga.mysql.com>2006-12-13 21:08:25 -0800
committerunknown <igor@olga.mysql.com>2006-12-13 21:08:25 -0800
commitcbd1bd90786025b98b9e510f770c5e3a0f3b23c6 (patch)
treed2a54ccb335e917d32f0e7f7c6cf236039ea34d5
parent2f78d5ca81e39c55aa918758a1f9b4e46ce76d74 (diff)
downloadmariadb-git-cbd1bd90786025b98b9e510f770c5e3a0f3b23c6.tar.gz
Fixed bug #25027.
Blocked evaluation of constant objects of the classes Item_func_is_null and Item_is_not_null_test at the prepare phase in the cases when the objects used subqueries. mysql-test/r/ps.result: Extended test case for bug #25027. mysql-test/t/ps.test: Extended test case for bug #25027. sql/sql_lex.cc: Returned back the assertion in st_select_lex_unit::set_limit, removed by the previous commit for this bug.
-rw-r--r--mysql-test/r/ps.result7
-rw-r--r--mysql-test/t/ps.test5
-rw-r--r--sql/item_cmpfunc.cc6
-rw-r--r--sql/item_cmpfunc.h3
-rw-r--r--sql/sql_lex.cc1
5 files changed, 18 insertions, 4 deletions
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index b5a9367c985..000a9317b8d 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -1528,5 +1528,12 @@ a
1
2
DEALLOCATE PREPARE stmt;
+PREPARE stmt FROM 'SELECT a FROM t1 WHERE (SELECT b FROM t2 limit ?) IS NULL';
+SET @arg=1;
+EXECUTE stmt USING @arg;
+a
+1
+2
+DEALLOCATE PREPARE stmt;
DROP TABLE t1,t2;
End of 5.0 tests.
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index 9386436a1fd..f6de2a40efa 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -1577,8 +1577,13 @@ SELECT a FROM t1 WHERE (SELECT b FROM t2) IS NULL;
PREPARE stmt FROM 'SELECT a FROM t1 WHERE (SELECT b FROM t2) IS NULL';
EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+PREPARE stmt FROM 'SELECT a FROM t1 WHERE (SELECT b FROM t2 limit ?) IS NULL';
+SET @arg=1;
+EXECUTE stmt USING @arg;
DEALLOCATE PREPARE stmt;
+
DROP TABLE t1,t2;
--echo End of 5.0 tests.
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 29fa049b6c4..0a7cbbb51cb 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -2990,7 +2990,7 @@ longlong Item_func_isnull::val_int()
Handle optimization if the argument can't be null
This has to be here because of the test in update_used_tables().
*/
- if (!used_tables_cache)
+ if (!used_tables_cache && !with_subselect)
return cached_value;
return args[0]->is_null() ? 1: 0;
}
@@ -2999,7 +2999,7 @@ longlong Item_is_not_null_test::val_int()
{
DBUG_ASSERT(fixed == 1);
DBUG_ENTER("Item_is_not_null_test::val_int");
- if (!used_tables_cache)
+ if (!used_tables_cache && !with_subselect)
{
owner->was_null|= (!cached_value);
DBUG_PRINT("info", ("cached :%ld", (long) cached_value));
@@ -3026,7 +3026,7 @@ void Item_is_not_null_test::update_used_tables()
else
{
args[0]->update_used_tables();
- if (!(used_tables_cache=args[0]->used_tables()))
+ if (!(used_tables_cache=args[0]->used_tables()) && !with_subselect)
{
/* Remember if the value is always NULL or never NULL */
cached_value= (longlong) !args[0]->is_null();
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index acad1e51bc9..faeee0d5567 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -1028,7 +1028,8 @@ public:
else
{
args[0]->update_used_tables();
- if ((const_item_cache= !(used_tables_cache= args[0]->used_tables())))
+ if ((const_item_cache= !(used_tables_cache= args[0]->used_tables())) &&
+ !with_subselect)
{
/* Remember if the value is always NULL or never NULL */
cached_value= (longlong) args[0]->is_null();
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index f5ec0c1161d..3de842c8551 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1903,6 +1903,7 @@ void st_select_lex_unit::set_limit(SELECT_LEX *sl)
{
ha_rows select_limit_val;
+ DBUG_ASSERT(! thd->stmt_arena->is_stmt_prepare());
select_limit_val= (ha_rows)(sl->select_limit ? sl->select_limit->val_uint() :
HA_POS_ERROR);
offset_limit_cnt= (ha_rows)(sl->offset_limit ? sl->offset_limit->val_uint() :