Commit 5933081d authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

MDEV-18163 Assertion `table_share->tmp_table != NO_TMP_TABLE || m_lock_type !=...

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)

Add the same check for altering DEFAULT used as for CREATE TABLE.
parent b3a9fbdb
...@@ -2506,5 +2506,16 @@ t2 CREATE TABLE `t2` ( ...@@ -2506,5 +2506,16 @@ t2 CREATE TABLE `t2` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
DROP TABLE t2, t1; 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 # End of 10.2 tests
# #
...@@ -2030,6 +2030,20 @@ ALTER TABLE t2 DROP CONSTRAINT PRIMARY KEY; ...@@ -2030,6 +2030,20 @@ ALTER TABLE t2 DROP CONSTRAINT PRIMARY KEY;
SHOW CREATE TABLE t2; SHOW CREATE TABLE t2;
DROP TABLE t2, t1; 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 #
--echo # End of 10.2 tests --echo # End of 10.2 tests
--echo # --echo #
...@@ -7692,6 +7692,8 @@ alter_list_item: ...@@ -7692,6 +7692,8 @@ alter_list_item:
| ALTER opt_column field_ident SET DEFAULT column_default_expr | ALTER opt_column field_ident SET DEFAULT column_default_expr
{ {
LEX *lex=Lex; 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); Alter_column *ac= new (thd->mem_root) Alter_column($3.str,$6);
if (ac == NULL) if (ac == NULL)
MYSQL_YYABORT; MYSQL_YYABORT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment