summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2020-10-02 17:30:02 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2020-10-02 17:30:02 +0200
commitbbce9b97bf68dd9a3fefc0065a4ba516c379c2d7 (patch)
tree57d39723390722d863f970e22fb90b5fa8552861
parentb8b1aef6b1a30349c989536aa80d06f38742c29e (diff)
downloadmariadb-git-bb-10.2-MDEV-18163.tar.gz
MDEV-18163 Assertion `table_share->tmp_table != NO_TMP_TABLE || m_lock_type != 2' failed in handler::ha_rnd_next(); / Assertion `table_list->table' failed in find_field_in_table_ref / ERROR 1901 (on optimized builds)bb-10.2-MDEV-18163
Add the same check for altering DEFAULT used as for CREATE TABLE.
-rw-r--r--mysql-test/r/alter_table.result11
-rw-r--r--mysql-test/t/alter_table.test14
-rw-r--r--sql/sql_yacc.yy2
3 files changed, 27 insertions, 0 deletions
diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result
index b4379f49c7e..69322bb9028 100644
--- a/mysql-test/r/alter_table.result
+++ b/mysql-test/r/alter_table.result
@@ -2506,5 +2506,16 @@ t2 CREATE TABLE `t2` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DROP TABLE t2, t1;
#
+# MDEV-18163: Assertion `table_share->tmp_table != NO_TMP_TABLE ||
+# m_lock_type != 2' failed in handler::ha_rnd_next(); / Assertion
+# `table_list->table' failed in find_field_in_table_ref / ERROR 1901
+# (on optimized builds)
+#
+CREATE TABLE t1 (k1 varchar(10) DEFAULT 5);
+CREATE TABLE t2 (i1 int);
+ALTER TABLE t1 ALTER COLUMN k1 SET DEFAULT (SELECT 1 FROM t2 limit 1);
+ERROR HY000: Function or expression 'select ...' cannot be used in the DEFAULT clause of `k1`
+DROP TABLE t1,t2;
+#
# End of 10.2 tests
#
diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test
index 0f685c470ad..2f1a40cbacd 100644
--- a/mysql-test/t/alter_table.test
+++ b/mysql-test/t/alter_table.test
@@ -2031,5 +2031,19 @@ SHOW CREATE TABLE t2;
DROP TABLE t2, t1;
--echo #
+--echo # MDEV-18163: Assertion `table_share->tmp_table != NO_TMP_TABLE ||
+--echo # m_lock_type != 2' failed in handler::ha_rnd_next(); / Assertion
+--echo # `table_list->table' failed in find_field_in_table_ref / ERROR 1901
+--echo # (on optimized builds)
+--echo #
+
+
+CREATE TABLE t1 (k1 varchar(10) DEFAULT 5);
+CREATE TABLE t2 (i1 int);
+--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
+ALTER TABLE t1 ALTER COLUMN k1 SET DEFAULT (SELECT 1 FROM t2 limit 1);
+DROP TABLE t1,t2;
+
+--echo #
--echo # End of 10.2 tests
--echo #
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 386c86cb3e2..138d5e13701 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -7692,6 +7692,8 @@ alter_list_item:
| ALTER opt_column field_ident SET DEFAULT column_default_expr
{
LEX *lex=Lex;
+ if (check_expression($6, $3.str, VCOL_DEFAULT))
+ MYSQL_YYABORT;
Alter_column *ac= new (thd->mem_root) Alter_column($3.str,$6);
if (ac == NULL)
MYSQL_YYABORT;