Skip to content

Commit 5933081

Browse files
committed
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.
1 parent b3a9fbd commit 5933081

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

mysql-test/r/alter_table.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2506,5 +2506,16 @@ t2 CREATE TABLE `t2` (
25062506
) ENGINE=InnoDB DEFAULT CHARSET=latin1
25072507
DROP TABLE t2, t1;
25082508
#
2509+
# MDEV-18163: Assertion `table_share->tmp_table != NO_TMP_TABLE ||
2510+
# m_lock_type != 2' failed in handler::ha_rnd_next(); / Assertion
2511+
# `table_list->table' failed in find_field_in_table_ref / ERROR 1901
2512+
# (on optimized builds)
2513+
#
2514+
CREATE TABLE t1 (k1 varchar(10) DEFAULT 5);
2515+
CREATE TABLE t2 (i1 int);
2516+
ALTER TABLE t1 ALTER COLUMN k1 SET DEFAULT (SELECT 1 FROM t2 limit 1);
2517+
ERROR HY000: Function or expression 'select ...' cannot be used in the DEFAULT clause of `k1`
2518+
DROP TABLE t1,t2;
2519+
#
25092520
# End of 10.2 tests
25102521
#

mysql-test/t/alter_table.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,6 +2030,20 @@ ALTER TABLE t2 DROP CONSTRAINT PRIMARY KEY;
20302030
SHOW CREATE TABLE t2;
20312031
DROP TABLE t2, t1;
20322032

2033+
--echo #
2034+
--echo # MDEV-18163: Assertion `table_share->tmp_table != NO_TMP_TABLE ||
2035+
--echo # m_lock_type != 2' failed in handler::ha_rnd_next(); / Assertion
2036+
--echo # `table_list->table' failed in find_field_in_table_ref / ERROR 1901
2037+
--echo # (on optimized builds)
2038+
--echo #
2039+
2040+
2041+
CREATE TABLE t1 (k1 varchar(10) DEFAULT 5);
2042+
CREATE TABLE t2 (i1 int);
2043+
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
2044+
ALTER TABLE t1 ALTER COLUMN k1 SET DEFAULT (SELECT 1 FROM t2 limit 1);
2045+
DROP TABLE t1,t2;
2046+
20332047
--echo #
20342048
--echo # End of 10.2 tests
20352049
--echo #

sql/sql_yacc.yy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7692,6 +7692,8 @@ alter_list_item:
76927692
| ALTER opt_column field_ident SET DEFAULT column_default_expr
76937693
{
76947694
LEX *lex=Lex;
7695+
if (check_expression($6, $3.str, VCOL_DEFAULT))
7696+
MYSQL_YYABORT;
76957697
Alter_column *ac= new (thd->mem_root) Alter_column($3.str,$6);
76967698
if (ac == NULL)
76977699
MYSQL_YYABORT;

0 commit comments

Comments
 (0)