1
0
mirror of https://github.com/MariaDB/server.git synced 2026-10-23 18:49:29 +03:00

MDEV-28650 Server crashes in Item_func_nextval::val_int after select from view

default_used was missing as view is parsed on its own
lex. extend_table_list() decides maybe_need_prelocking based on
default_used and prelocking_strategy->handle_table() was skipped for
view, so internal_tables was not updated (they could be stale from
previous statement).
This commit is contained in:
Aleksey Midenkov
2025-12-22 18:45:32 +03:00
parent b061b5ab1f
commit 7a88776dc1
3 changed files with 85 additions and 0 deletions

View File

@@ -548,3 +548,56 @@ SELECT SETVAL (v,0);
ERROR 42S02: 'test.v' is not a SEQUENCE
UNLOCK TABLES;
DROP VIEW v;
#
# MDEV-28650 Server crashes in Item_func_nextval::val_int after select from view
#
create sequence s;
create table t1 (a int not null default nextval(s));
insert into t1 values(),();
flush tables;
select default(a) from t1;
default(a)
1001
1002
create algorithm=merge view v1 as select default(a) from t1;
select * from v1;
default(a)
1003
1004
Select * from v1;
default(a)
1005
1006
prepare ps from 'SELECT * from v1';
execute ps;
default(a)
1007
1008
Execute ps;
default(a)
1009
1010
drop prepare ps;
create or replace algorithm=temptable view v1 as select default(a) from t1;
select * from v1;
default(a)
1011
1012
Select * from v1;
default(a)
1013
1014
prepare ps from 'SELECT * from v1';
execute ps;
default(a)
1015
1016
Execute ps;
default(a)
1017
1018
drop prepare ps;
drop view v1;
drop table t1;
drop sequence s;
# End of 10.11 tests

View File

@@ -299,3 +299,33 @@ SELECT SETVAL (v,0);
UNLOCK TABLES;
DROP VIEW v;
--disable_ps2_protocol
--echo #
--echo # MDEV-28650 Server crashes in Item_func_nextval::val_int after select from view
--echo #
create sequence s;
create table t1 (a int not null default nextval(s));
insert into t1 values(),();
flush tables;
select default(a) from t1;
create algorithm=merge view v1 as select default(a) from t1;
select * from v1;
Select * from v1;
prepare ps from 'SELECT * from v1';
execute ps; Execute ps;
drop prepare ps;
create or replace algorithm=temptable view v1 as select default(a) from t1;
select * from v1;
Select * from v1;
prepare ps from 'SELECT * from v1';
execute ps; Execute ps;
drop prepare ps;
# cleanup
drop view v1;
drop table t1;
drop sequence s;
--echo # End of 10.11 tests

View File

@@ -1720,6 +1720,8 @@ bool mysql_make_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table,
if (lex->first_select_lex()->options & OPTION_TO_QUERY_CACHE)
old_lex->first_select_lex()->options|= OPTION_TO_QUERY_CACHE;
old_lex->default_used= lex->default_used;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (table->view_suid)
{