mirror of
https://github.com/MariaDB/server.git
synced 2025-09-02 09:41:40 +03:00
WL#4165 "Prepared statements: validation".
Add metadata validation to ~20 more SQL commands. Make sure that these commands actually work in ps-protocol, since until now they were enabled, but not carefully tested. Fixes the ml003 bug found by Matthias during internal testing of the patch. mysql-test/r/ps_ddl.result: Update test results (WL#4165) mysql-test/t/ps_ddl.test: Cover with tests metadata validation of 26 SQL statements. sql/mysql_priv.h: Fix the name in the comment. sql/sp_head.cc: Changed the way the observer is removed in case of stored procedures to support validation prepare stmt from "call p1(<expr>)": whereas tables used in the expression must be validated, substatements of p1 must not. The previous scheme used to silence the observer only in stored functions and triggers. sql/sql_class.cc: Now the observer is silenced in sp_head::execute(). Remove it from Sub_statement_state. sql/sql_class.h: Now the observer is silenced in sp_head::execute(). Remove it from Sub_statement_state. sql/sql_parse.cc: Add CF_REEXECUTION_FRAGILE to 20 more SQLCOMs that need it. sql/sql_prepare.cc: Add metadata validation to ~20 new SQLCOMs that need it. Fix memory leaks with expressions used in SHOW DATABASES and CALL (and prepared statements). We need to fix all expressions at prepare, since if these expressions use subqueries, there are one-time transformations of the parse tree that must be done at prepare. List of fixed commands includes: SHOW TABLES, SHOW DATABASES, SHOW TRIGGERS, SHOW EVENTS, SHOW OPEN TABLES,SHOW KEYS, SHOW FIELDS, SHOW COLLATIONS, SHOW CHARSETS, SHOW VARIABLES, SHOW TATUS, SHOW TABLE STATUS, SHOW PROCEDURE STATUS, SHOW FUNCTION STATUS, CALL. Add comment to set_parameters(). sql/table.h: Update comments.
This commit is contained in:
@@ -45,7 +45,7 @@
|
||||
At most 1 instance of this class is active at a time, in which
|
||||
case THD::m_metadata_observer is not NULL.
|
||||
|
||||
@sa check_and_update_metadata_version() for details of the
|
||||
@sa check_and_update_table_version() for details of the
|
||||
version tracking algorithm
|
||||
|
||||
@sa Execute_observer for details of how we detect that
|
||||
@@ -847,7 +847,7 @@ public:
|
||||
to avoid spurious ER_NEED_REPREPARE errors -- system and
|
||||
INFORMATION_SCHEMA tables are not subject to metadata version
|
||||
tracking.
|
||||
@sa check_and_update_metadata_version()
|
||||
@sa check_and_update_table_version()
|
||||
*/
|
||||
Metadata_version_observer *m_metadata_observer;
|
||||
|
||||
@@ -983,25 +983,6 @@ public:
|
||||
bool enable_slow_log;
|
||||
bool last_insert_id_used;
|
||||
SAVEPOINT *savepoints;
|
||||
/**
|
||||
When inside a substatement (a stored function or trigger
|
||||
statement), clear the metadata observer in THD, if any.
|
||||
Remember the value of the observer here, to be able
|
||||
to restore it when leaving the substatement.
|
||||
|
||||
We reset the observer to suppress errors when a substatement
|
||||
uses temporary tables. If a temporary table does not exist
|
||||
at start of the main statement, it's not prelocked
|
||||
and thus is not validated with other prelocked tables.
|
||||
|
||||
Later on, when the temporary table is opened, metadata
|
||||
versions mismatch, expectedly.
|
||||
|
||||
The proper solution for the problem is to re-validate tables
|
||||
of substatements (Bug#12257, Bug#27011, Bug#32868, Bug#33000),
|
||||
but it's not implemented yet.
|
||||
*/
|
||||
Metadata_version_observer *m_metadata_observer;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user