summaryrefslogtreecommitdiff
path: root/mysql-test/t/sp-vars.test
diff options
context:
space:
mode:
authorthek@adventure.(none) <>2007-05-18 12:44:03 +0200
committerthek@adventure.(none) <>2007-05-18 12:44:03 +0200
commit637f85ca21a5d776a5c9ced149b9c7088123c2c5 (patch)
tree8813ca4bdc7ac37e0e63cf0fc7df420a2b11353e /mysql-test/t/sp-vars.test
parente22cbec571d657db1e068c60e92a89438c72cccb (diff)
downloadmariadb-git-637f85ca21a5d776a5c9ced149b9c7088123c2c5.tar.gz
Bug#26277 User variable returns one type in SELECT @v and other for CREATE as SELECT @v
- Adding variable m_cached_result_type to keep the variable type consistent during the execution of a statement. - Before each result set is returned to the client the description of each column is sent as meta data. Previously the result type for a column could change if the hash variable entry changed between statements. This caused the result set of the query to alternate column types in certain cases which is not supported by MySQL client-server protocol. Example: Previously this sequence: SET @a:=1; SELECT @a:="text", @a; would return "text", "text"; After the change the SELECT returns "text", 0 The reson for this is that previously the result set from 'SELECT @a;' would always be of the type STRING, whereas now the type of the variable is taken from the last SET statement. However, 'SELECT @a:="text"' will return type of STRING since the right side of the assignment is used.
Diffstat (limited to 'mysql-test/t/sp-vars.test')
-rw-r--r--mysql-test/t/sp-vars.test36
1 files changed, 36 insertions, 0 deletions
diff --git a/mysql-test/t/sp-vars.test b/mysql-test/t/sp-vars.test
index 0014dc1f6af..9f59c7fb680 100644
--- a/mysql-test/t/sp-vars.test
+++ b/mysql-test/t/sp-vars.test
@@ -1368,3 +1368,39 @@ CALL p1();
DROP PROCEDURE p1;
# End of 5.0 tests.
+
+#
+# Bug #26277 User variable returns one type in SELECT @v and other for CREATE as SELECT @v
+#
+--disable_warnings
+drop function if exists f1;
+drop table if exists t1;
+--enable_warnings
+
+delimiter |;
+create function f1() returns int
+begin
+ if @a=1 then set @b='abc';
+ else set @b=1;
+ end if;
+ set @a=1;
+ return 0;
+end|
+
+create table t1 (a int)|
+insert into t1 (a) values (1), (2)|
+
+set @b=1|
+set @a=0|
+select f1(), @b from t1|
+
+set @b:='test'|
+set @a=0|
+select f1(), @b from t1|
+
+delimiter ;|
+
+drop function f1;
+drop table t1;
+# End of 5.1 tests.
+