diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2019-04-17 15:50:59 +0200 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2022-01-24 14:41:06 +0100 |
commit | 349283c5e7a3a338445140156e866d6ade939edf (patch) | |
tree | ee5f87b18649f9b4ac55239bce87826c0f06bc31 /sql/sql_base.cc | |
parent | ecfa9361406f9007af8a808567909a519aa9984b (diff) | |
download | mariadb-git-bb-10.2-MDEV-17124.tar.gz |
MDEV-17124: mariadb 10.1.34, views and prepared statements: ERROR 1615 (HY000): Prepared statement needs to be re-preparedbb-10.2-MDEV-17124
The problem is that if table definition cache (TDC) is full of real tables
which are in tables cache, view definition can not stay there so will be
removed by its own underlying tables.
In situation above old mechanism of detection matching definition in PS
and current version always require reprepare and so prevent executing
the PS.
One work around is to increase TDC, other - improve version check for
views/triggers (which is done here). Now in suspicious cases we check:
- timestamp (ms) of the view to be sure that version really have changed;
- time (ms) of creation of a trigger related to time (ms) of statement
preparation.
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r-- | sql/sql_base.cc | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 248dedf36e4..85bf6f05d02 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1839,6 +1839,10 @@ retry_share: goto err_lock; } + /* Open view */ + if (mysql_make_view(thd, share, table_list, false)) + goto err_lock; + /* This table is a view. Validate its metadata version: in particular, that it was a view when the statement was prepared. @@ -1846,10 +1850,6 @@ retry_share: if (check_and_update_table_version(thd, table_list, share)) goto err_lock; - /* Open view */ - if (mysql_make_view(thd, share, table_list, false)) - goto err_lock; - /* TODO: Don't free this */ tdc_release_share(share); @@ -2643,7 +2643,7 @@ static bool check_and_update_table_version(THD *thd, TABLE_LIST *tables, TABLE_SHARE *table_share) { - if (! tables->is_table_ref_id_equal(table_share)) + if (! tables->is_table_ref_id_equal(thd, table_share)) { if (thd->m_reprepare_observer && thd->m_reprepare_observer->report_error(thd)) @@ -2749,7 +2749,9 @@ bool tdc_open_view(THD *thd, TABLE_LIST *table_list, uint flags) DBUG_ASSERT(share->is_view); - if (flags & CHECK_METADATA_VERSION) + err= mysql_make_view(thd, share, table_list, (flags & OPEN_VIEW_NO_PARSE)); + + if (!err && (flags & CHECK_METADATA_VERSION)) { /* Check TABLE_SHARE-version of view only if we have been instructed to do @@ -2764,7 +2766,6 @@ bool tdc_open_view(THD *thd, TABLE_LIST *table_list, uint flags) goto ret; } - err= mysql_make_view(thd, share, table_list, (flags & OPEN_VIEW_NO_PARSE)); ret: tdc_release_share(share); |