diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2018-11-13 10:10:09 +0100 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2018-11-13 10:10:09 +0100 |
commit | 5e63f616a7ed511e6e69581f6659f60f1ec8633b (patch) | |
tree | 5939124c3b798374f9c76f022206ca66d3f4034a /sql/sql_view.cc | |
parent | 1368a63589d0b4900f7d7efb57444c4ea34e6c26 (diff) | |
download | mariadb-git-bb-10.1-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.1-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 me 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 arount is to increase TDC, other - improve version check for views (which is done here).
Now in suspiciouse cases we check MD5 of the view to be sure that version really have chenged.
Diffstat (limited to 'sql/sql_view.cc')
-rw-r--r-- | sql/sql_view.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 9a9309a133b..ee169de4c93 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -782,6 +782,16 @@ static File_option view_parameters[]= FILE_OPTIONS_STRING} }; + +static File_option view_md5_parameters[]= +{ + + {{ C_STRING_WITH_LEN("md5")}, 0, FILE_OPTIONS_FIXSTRING}, + {{NullS, 0}, 0, FILE_OPTIONS_STRING} +}; + + + static LEX_STRING view_file_type[]= {{(char*) STRING_WITH_LEN("VIEW") }}; @@ -1125,7 +1135,38 @@ err: DBUG_RETURN(error); } +#define MD5_LEN 32 +/** + Check is TABLE_LEST and SHARE match + @param[in] view TABLE_LIST of the view + @param[in] share Share object of view + + @return false on error or misspatch +*/ +bool mariadb_view_version_check(TABLE_LIST *view, TABLE_SHARE *share) +{ + LEX_STRING md5; + char md5_buffer[MD5_LEN + 1]; + md5.str= md5_buffer; + md5.length= MD5_LEN; + + /* + Check that both were views (view->is_view() could not be checked + because it is not opened). + */ + if (!share->is_view || view->md5.length != MD5_LEN) + return FALSE; + + DBUG_ASSERT(share->view_def != NULL); + if (share->view_def->parse((uchar*)&md5, NULL, + view_md5_parameters, + 1, + &file_parser_dummy_hook)) + return FALSE; + DBUG_ASSERT(md5.length == MD5_LEN); + return (strncmp(md5.str, view->md5.str, MD5_LEN) == 0); +} /** read VIEW .frm and create structures |