MDEV-34669: ER_NEED_REPREPARE on SELECT DEFAULT(name) FROM table1_containing_sequence

A prepared SELECT statement because of CF_REEXECUTION_FRAGILE needs to
check the table is the same definition as previously otherwise a
re-prepare of the statement can occur.

When running many 'SELECT DEFAULT(name) FROM table1_containing_sequence'
in parallel the TABLE_LIST::is_the_same_definition may be called when
m_table_ref_type is TABLE_REF_NULL because it hasn't been checked yet.

In this case populate the TABLE_LIST with the values determined by the
TABLE_SHARE and allow the execution to continue.

As a result of this, the main.ps_ddl test doesn't need to reprepare
as the defination hasn't changed. This is another case where
TABLE_LIST::is_the_same_definition is called when m_table_ref_type is
TABLE_REF_NULL, but that doesn't mean that the defination is different.
This commit is contained in:
Daniel Black 2024-07-30 13:20:39 +10:00
parent ab9182470d
commit 6dcd9de2a9
3 changed files with 9 additions and 2 deletions

View file

@ -2037,7 +2037,7 @@ SUCCESS
execute stmt;
Warnings:
Note 1050 Table 't2' already exists
call p_verify_reprepare_count(1);
call p_verify_reprepare_count(0);
SUCCESS
select * from t2;

View file

@ -1680,7 +1680,7 @@ drop table t2;
execute stmt;
call p_verify_reprepare_count(0);
execute stmt;
call p_verify_reprepare_count(1);
call p_verify_reprepare_count(0);
select * from t2;
execute stmt;
call p_verify_reprepare_count(0);

View file

@ -9727,7 +9727,14 @@ bool TABLE_LIST::is_the_same_definition(THD* thd, TABLE_SHARE *s)
tabledef_version.length= 0;
}
else
{
set_tabledef_version(s);
if (m_table_ref_type == TABLE_REF_NULL)
{
set_table_ref_id(s);
return TRUE;
}
}
return FALSE;
}