diff options
author | unknown <kroki/tomash@moonlight.intranet> | 2006-10-10 13:44:04 +0400 |
---|---|---|
committer | unknown <kroki/tomash@moonlight.intranet> | 2006-10-10 13:44:04 +0400 |
commit | 469ff92d81d496862ed1fcb7cf700390b7c2de72 (patch) | |
tree | 570b1da7c2c4f38e5729d20b5028727367d6045a /sql/sql_base.cc | |
parent | 44a40f1dd4ea8ea2dbf12fd7fd851948a659aef0 (diff) | |
download | mariadb-git-469ff92d81d496862ed1fcb7cf700390b7c2de72.tar.gz |
Bug#19111: TRIGGERs selecting from a VIEW on the firing base table fail.
In a trigger or a function used in a statement it is possible to do
SELECT from a table being modified by the statement. However,
encapsulation of such SELECT into a view and selecting from a view
instead of direct SELECT was not possible.
This happened because tables used by views (which in their turn
were used from functions/triggers) were not excluded from checks
in unique_table() routine as it happens for the rest of tables
added to the statement table list for prelocking.
With this fix we ignore all such tables in unique_table(), thus
providing consistency: inside a trigger or a functions SELECT from
a view may be used where plain SELECT is allowed. Modification of
the same table from function or trigger is still disallowed. Also,
this patch doesn't affect the case where SELECT from the table being
modified is done outside of function of trigger, such SELECTs are
still disallowed (this limitation and visibility problem when function
select from a table being modified are subjects of bug 21326). See
also bug 22427.
mysql-test/r/view.result:
Add result for bug#19111: TRIGGERs selecting from a VIEW on the
firing base table fail.
mysql-test/t/view.test:
Add test case for bug#19111: TRIGGERs selecting from a VIEW on the
firing base table fail.
sql/sql_base.cc:
In unique_table() do not check tables that are used in a stored
function or a trigger ('prelocking_placeholder' is set). If such
function or a trigger will attempt to modify a table, the error will
be given, however select is allowed there.
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r-- | sql/sql_base.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 5383bb52aaa..858d820c85e 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -805,6 +805,10 @@ TABLE_LIST *find_table_in_list(TABLE_LIST *table, Also SELECT::exclude_from_table_unique_test used to exclude from check tables of main SELECT of multi-delete and multi-update + We also skip tables with TABLE_LIST::prelocking_placeholder set, + because we want to allow SELECTs from them, and their modification + will rise the error anyway. + TODO: when we will have table/view change detection we can do this check only once for PS/SP @@ -851,12 +855,13 @@ TABLE_LIST* unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list) if (((! (res= find_table_in_global_list(table_list, d_name, t_name))) && (! (res= mysql_lock_have_duplicate(thd, table, table_list)))) || ((!res->table || res->table != table->table) && - res->select_lex && !res->select_lex->exclude_from_table_unique_test)) + res->select_lex && !res->select_lex->exclude_from_table_unique_test && + !res->prelocking_placeholder)) break; /* - If we found entry of this table or or table of SELECT which already + If we found entry of this table or table of SELECT which already processed in derived table or top select of multi-update/multi-delete - (exclude_from_table_unique_test). + (exclude_from_table_unique_test) or prelocking placeholder. */ table_list= res->next_global; DBUG_PRINT("info", |