mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-13020 Server crashes in Item_func_nextval::val_int...
The problem was that we didn't check on open of sequence if the table is a view, which is not allowed. We are now generating a proper error message for this case.
This commit is contained in:
26
mysql-test/suite/sql_sequence/view.result
Normal file
26
mysql-test/suite/sql_sequence/view.result
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
create sequence s1;
|
||||||
|
create view v1 as select * from s1;
|
||||||
|
create view v2 as select next value for s1;
|
||||||
|
select * from v1;
|
||||||
|
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
|
||||||
|
1 1 9223372036854775806 1 1 1000 0 0
|
||||||
|
select * from v2;
|
||||||
|
next value for s1
|
||||||
|
1
|
||||||
|
select * from v2;
|
||||||
|
next value for s1
|
||||||
|
2
|
||||||
|
select next value for v1;
|
||||||
|
ERROR 42S02: 'test.v1' is not a SEQUENCE
|
||||||
|
drop sequence s1;
|
||||||
|
drop view v1,v2;
|
||||||
|
#
|
||||||
|
# MDEV 13020 Server crashes in Item_func_nextval::val_int upon
|
||||||
|
# selecting NEXT or PREVIOUS VALUE for a view
|
||||||
|
#
|
||||||
|
CREATE OR REPLACE VIEW v1 AS SELECT 1 AS f;
|
||||||
|
SELECT NEXT VALUE FOR v1;
|
||||||
|
ERROR 42S02: 'test.v1' is not a SEQUENCE
|
||||||
|
SELECT PREVIOUS VALUE FOR v1;
|
||||||
|
ERROR 42S02: 'test.v1' is not a SEQUENCE
|
||||||
|
drop view v1;
|
29
mysql-test/suite/sql_sequence/view.test
Normal file
29
mysql-test/suite/sql_sequence/view.test
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
--source include/have_sequence.inc
|
||||||
|
--source include/have_innodb.inc
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test sequences with views
|
||||||
|
#
|
||||||
|
|
||||||
|
create sequence s1;
|
||||||
|
create view v1 as select * from s1;
|
||||||
|
create view v2 as select next value for s1;
|
||||||
|
select * from v1;
|
||||||
|
select * from v2;
|
||||||
|
select * from v2;
|
||||||
|
--error ER_NOT_SEQUENCE
|
||||||
|
select next value for v1;
|
||||||
|
drop sequence s1;
|
||||||
|
drop view v1,v2;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV 13020 Server crashes in Item_func_nextval::val_int upon
|
||||||
|
--echo # selecting NEXT or PREVIOUS VALUE for a view
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW v1 AS SELECT 1 AS f;
|
||||||
|
--error ER_NOT_SEQUENCE
|
||||||
|
SELECT NEXT VALUE FOR v1;
|
||||||
|
--error ER_NOT_SEQUENCE
|
||||||
|
SELECT PREVIOUS VALUE FOR v1;
|
||||||
|
drop view v1;
|
@ -1783,7 +1783,11 @@ retry_share:
|
|||||||
my_error(ER_WRONG_MRG_TABLE, MYF(0));
|
my_error(ER_WRONG_MRG_TABLE, MYF(0));
|
||||||
goto err_lock;
|
goto err_lock;
|
||||||
}
|
}
|
||||||
|
if (table_list->sequence)
|
||||||
|
{
|
||||||
|
my_error(ER_NOT_SEQUENCE, MYF(0), table_list->db, table_list->alias);
|
||||||
|
goto err_lock;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
This table is a view. Validate its metadata version: in particular,
|
This table is a view. Validate its metadata version: in particular,
|
||||||
that it was a view when the statement was prepared.
|
that it was a view when the statement was prepared.
|
||||||
@ -1936,8 +1940,8 @@ retry_share:
|
|||||||
#endif
|
#endif
|
||||||
if (table_list->sequence && table->s->table_type != TABLE_TYPE_SEQUENCE)
|
if (table_list->sequence && table->s->table_type != TABLE_TYPE_SEQUENCE)
|
||||||
{
|
{
|
||||||
my_error(ER_NOT_SEQUENCE, MYF(0), table_list->db, table_list->alias);
|
my_error(ER_NOT_SEQUENCE, MYF(0), table_list->db, table_list->alias);
|
||||||
DBUG_RETURN(true);
|
DBUG_RETURN(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
table->init(thd, table_list);
|
table->init(thd, table_list);
|
||||||
|
Reference in New Issue
Block a user