summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/query_cache.result19
-rw-r--r--mysql-test/r/sp.result8
-rw-r--r--mysql-test/t/query_cache.test15
-rw-r--r--mysql-test/t/sp.test10
-rw-r--r--sql/sql_lex.h29
5 files changed, 68 insertions, 13 deletions
diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result
index eb9b1d16011..ee734845a9e 100644
--- a/mysql-test/r/query_cache.result
+++ b/mysql-test/r/query_cache.result
@@ -2168,6 +2168,25 @@ show status like "Qcache_hits";
Variable_name Value
Qcache_hits 1
drop table t1;
+#
+# MDEV-15328: MariaDB 10.2.13 Crashes upon CALL PROCEDURE PARAM
+# LAST_INSERT_ID ()
+# (part 2, part 1 is in sp.test)
+#
+create table t1 (a int);
+insert into t1 values (1);
+CREATE FUNCTION foo (i INT UNSIGNED ) RETURNS int deterministic RETURN 1;
+show status like "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 0
+SELECT foo( LAST_INSERT_ID() ) from t1;
+foo( LAST_INSERT_ID() )
+1
+show status like "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 0
+DROP FUNCTION foo;
+drop table t1;
restore defaults
SET GLOBAL query_cache_type= default;
SET GLOBAL query_cache_size= default;
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 9a9042bc8c9..0909e59c2c4 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -8415,3 +8415,11 @@ DROP FUNCTION f1;
DROP FUNCTION f2;
DROP FUNCTION f3;
DROP TABLE t1;
+#
+# MDEV-15328: MariaDB 10.2.13 Crashes upon CALL PROCEDURE PARAM
+# LAST_INSERT_ID ()
+# (part 1, part 2 is in query_cache.test)
+#
+CREATE PROCEDURE foo ( IN i INT UNSIGNED ) BEGIN END;
+CALL foo( LAST_INSERT_ID() );
+DROP PROCEDURE foo;
diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test
index c354032bc36..1b1e24bc6f4 100644
--- a/mysql-test/t/query_cache.test
+++ b/mysql-test/t/query_cache.test
@@ -1767,6 +1767,21 @@ show status like "Qcache_inserts";
show status like "Qcache_hits";
drop table t1;
+--echo #
+--echo # MDEV-15328: MariaDB 10.2.13 Crashes upon CALL PROCEDURE PARAM
+--echo # LAST_INSERT_ID ()
+--echo # (part 2, part 1 is in sp.test)
+--echo #
+
+create table t1 (a int);
+insert into t1 values (1);
+CREATE FUNCTION foo (i INT UNSIGNED ) RETURNS int deterministic RETURN 1;
+show status like "Qcache_queries_in_cache";
+SELECT foo( LAST_INSERT_ID() ) from t1;
+show status like "Qcache_queries_in_cache";
+DROP FUNCTION foo;
+drop table t1;
+
--echo restore defaults
SET GLOBAL query_cache_type= default;
SET GLOBAL query_cache_size= default;
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 5ddf4153497..df0fb15e72d 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -9932,3 +9932,13 @@ DROP FUNCTION f1;
DROP FUNCTION f2;
DROP FUNCTION f3;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-15328: MariaDB 10.2.13 Crashes upon CALL PROCEDURE PARAM
+--echo # LAST_INSERT_ID ()
+--echo # (part 1, part 2 is in query_cache.test)
+--echo #
+
+CREATE PROCEDURE foo ( IN i INT UNSIGNED ) BEGIN END;
+CALL foo( LAST_INSERT_ID() );
+DROP PROCEDURE foo;
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 373c7843648..1bf39798841 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -3033,21 +3033,24 @@ public:
{
safe_to_cache_query= 0;
- /*
- There are no sense to mark select_lex and union fields of LEX,
- but we should merk all subselects as uncacheable from current till
- most upper
- */
- SELECT_LEX *sl;
- SELECT_LEX_UNIT *un;
- for (sl= current_select, un= sl->master_unit();
- un != &unit;
- sl= sl->outer_select(), un= sl->master_unit())
+ if (current_select) // initialisation SP variables has no SELECT
{
- sl->uncacheable|= cause;
- un->uncacheable|= cause;
+ /*
+ There are no sense to mark select_lex and union fields of LEX,
+ but we should merk all subselects as uncacheable from current till
+ most upper
+ */
+ SELECT_LEX *sl;
+ SELECT_LEX_UNIT *un;
+ for (sl= current_select, un= sl->master_unit();
+ un != &unit;
+ sl= sl->outer_select(), un= sl->master_unit())
+ {
+ sl->uncacheable|= cause;
+ un->uncacheable|= cause;
+ }
+ select_lex.uncacheable|= cause;
}
- select_lex.uncacheable|= cause;
}
void set_trg_event_type_for_tables();