Commit 5c896472 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-25672 table alias from previous statement interferes later commands

only perform the "correct table name" check for *new* generated columns,
but not for already existing ones - they're guaranteed to be valid
parent 2e789108
drop table if exists t1;
set @OLD_SQL_MODE=@@SESSION.SQL_MODE; set @OLD_SQL_MODE=@@SESSION.SQL_MODE;
create table t1 (a int, b int generated always as (a+1)); create table t1 (a int, b int generated always as (a+1));
show create table t1; show create table t1;
...@@ -88,3 +87,13 @@ create table t1 (x int, y int default test2.t1.x); ...@@ -88,3 +87,13 @@ create table t1 (x int, y int default test2.t1.x);
ERROR 42S22: Unknown column '`test2`.`t1`.`x`' in 'DEFAULT' ERROR 42S22: Unknown column '`test2`.`t1`.`x`' in 'DEFAULT'
create table t1 (x int, check (test2.t1.x > 0)); create table t1 (x int, check (test2.t1.x > 0));
ERROR 42S22: Unknown column '`test2`.`t1`.`x`' in 'CHECK' ERROR 42S22: Unknown column '`test2`.`t1`.`x`' in 'CHECK'
#
# MDEV-25672 table alias from previous statement interferes later commands
#
create table t1 (a int, v_a int generated always as (a));
update t1 as x set a = 1;
alter table t1 force;
drop table t1;
#
# End of 10.2 tests
#
# #
# test syntax # test syntax
# #
--disable_warnings
drop table if exists t1;
--enable_warnings
set @OLD_SQL_MODE=@@SESSION.SQL_MODE; set @OLD_SQL_MODE=@@SESSION.SQL_MODE;
create table t1 (a int, b int generated always as (a+1)); create table t1 (a int, b int generated always as (a+1));
show create table t1; show create table t1;
...@@ -72,3 +68,16 @@ create table t1 (x int, y int check (y > test2.t1.x)); ...@@ -72,3 +68,16 @@ create table t1 (x int, y int check (y > test2.t1.x));
create table t1 (x int, y int default test2.t1.x); create table t1 (x int, y int default test2.t1.x);
--error ER_BAD_FIELD_ERROR --error ER_BAD_FIELD_ERROR
create table t1 (x int, check (test2.t1.x > 0)); create table t1 (x int, check (test2.t1.x > 0));
--echo #
--echo # MDEV-25672 table alias from previous statement interferes later commands
--echo #
create table t1 (a int, v_a int generated always as (a));
update t1 as x set a = 1;
alter table t1 force;
drop table t1;
--echo #
--echo # End of 10.2 tests
--echo #
...@@ -2841,7 +2841,7 @@ class Item_field :public Item_ident, ...@@ -2841,7 +2841,7 @@ class Item_field :public Item_ident,
bool check_table_name_processor(void *arg) bool check_table_name_processor(void *arg)
{ {
Check_table_name_prm &p= *(Check_table_name_prm *) arg; Check_table_name_prm &p= *(Check_table_name_prm *) arg;
if (p.table_name.length && table_name) if (!field && p.table_name.length && table_name)
{ {
DBUG_ASSERT(p.db.length); DBUG_ASSERT(p.db.length);
if ((db_name && if ((db_name &&
......
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