summaryrefslogtreecommitdiff
path: root/mysql-test/t/errors.test
diff options
context:
space:
mode:
authorNorvald H. Ryeng <norvald.ryeng@oracle.com>2012-03-12 08:56:56 +0100
committerNorvald H. Ryeng <norvald.ryeng@oracle.com>2012-03-12 08:56:56 +0100
commitad031d51100555dd1b77baaa075d2f7c8790571b (patch)
tree2cfe41a2b14e022026f033a467d4720e7b218f14 /mysql-test/t/errors.test
parentc48233c61e6ab3a45f554de4d975f5c91b914822 (diff)
downloadmariadb-git-ad031d51100555dd1b77baaa075d2f7c8790571b.tar.gz
Bug#13031606 VALUES() IN A SELECT STATEMENT CRASHES SERVER
Problem: Grouping results by VALUES(alias for string literal) causes the server to crash. Item_insert_values is not constructed to handle other types of arguments than field and reference to field. In this case, the argument is an Item_string, and this causes Item_insert_values::fix_fields() to crash. Fix: Issue an error message when the argument to Item_insert_values is not a field or a reference to a field. This is slightly in breach with documentation, which states that VALUES should return NULL, but the error message is only issued in cases where the server otherwise would crash, so there is no change in behavior for queries that already work. Future versions will restrict syntax so that using VALUES in this way is illegal. mysql-test/r/errors.result: Add test case for bug #13031606. mysql-test/t/errors.test: Add test case for bug #13031606. sql/item.cc: Issue error message if argument is not field or reference to field.
Diffstat (limited to 'mysql-test/t/errors.test')
-rw-r--r--mysql-test/t/errors.test18
1 files changed, 18 insertions, 0 deletions
diff --git a/mysql-test/t/errors.test b/mysql-test/t/errors.test
index 89579ec1739..b426d9fd5b0 100644
--- a/mysql-test/t/errors.test
+++ b/mysql-test/t/errors.test
@@ -67,3 +67,21 @@ SHOW ERRORS;
INSERT INTO t1 SELECT b FROM t1;
DROP TABLE t1;
# End of 5.0 tests
+
+#
+# Bug #13031606 VALUES() IN A SELECT STATEMENT CRASHES SERVER
+#
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2(a INT PRIMARY KEY, b INT);
+--error ER_BAD_FIELD_ERROR
+SELECT '' AS b FROM t1 GROUP BY VALUES(b);
+--error ER_BAD_FIELD_ERROR
+REPLACE t2(b) SELECT '' AS b FROM t1 GROUP BY VALUES(b);
+--error ER_BAD_FIELD_ERROR
+UPDATE t2 SET a=(SELECT '' AS b FROM t1 GROUP BY VALUES(b));
+--error ER_BAD_FIELD_ERROR
+INSERT INTO t2 VALUES (1,0) ON DUPLICATE KEY UPDATE
+ b=(SELECT '' AS b FROM t1 GROUP BY VALUES(b));
+INSERT INTO t2(a,b) VALUES (1,0) ON DUPLICATE KEY UPDATE
+ b=(SELECT VALUES(a)+2 FROM t1);
+DROP TABLE t1, t2;