diff options
author | unknown <dlenev@mockturtle.local> | 2007-01-23 15:03:48 +0300 |
---|---|---|
committer | unknown <dlenev@mockturtle.local> | 2007-01-23 15:03:48 +0300 |
commit | 1dead07d1416201aba6d04ddfc7dc331dbf5a883 (patch) | |
tree | a4cc82a686762949344a19cd89efabc861513bd3 /sql/item.h | |
parent | 21311e992de836763ff81064b05eb01114aedc13 (diff) | |
download | mariadb-git-1dead07d1416201aba6d04ddfc7dc331dbf5a883.tar.gz |
Proposed fix for bug#24491 "using alias from source table in insert ...
on duplicate key".
INSERT ... SELECT ... ON DUPLICATE KEY UPDATE which was used in
stored routine or as prepared statement and which in its ON DUPLICATE
KEY clause erroneously tried to assign value to a column mentioned only
in its SELECT part was properly emitting error on the first execution
but succeeded on the second and following executions.
Code which is responsible for name resolution of fields mentioned in
UPDATE clause (e.g. see select_insert::prepare()) modifies table list
and Name_resolution_context used in this process. It uses
Name_resolution_context_state::save_state/restore_state() to revert
these modifications. Unfortunately those two methods failed to revert
properly modifications to TABLE_LIST::next_name_resolution_table
and this broke name resolution process for successive executions.
This patch fixes Name_resolution_context_state::save_state/restore_state()
in such way that it properly handles TABLE_LIST::next_name_resolution_table.
mysql-test/r/ps.result:
Added test case for bug#24491 "using alias from source table in insert ...
on duplicate key"
mysql-test/r/sp-error.result:
Added test case for bug#24491 "using alias from source table in insert ...
on duplicate key"
mysql-test/t/ps.test:
Added test case for bug#24491 "using alias from source table in insert ...
on duplicate key"
mysql-test/t/sp-error.test:
Added test case for bug#24491 "using alias from source table in insert ...
on duplicate key"
sql/item.h:
Name_resolution_context::save_state/restore_state():
At the moment these methods are used only by code implementing
INSERT and INSERT ... SELECT statements. This code doesn't modify
'next_name_resolution_table' member of table list element
corresponding to the first table of SELECT clause (pointed by
'first_name_resolution_table'). But it modifies table list element
corresponding to the target table of INSERT (pointed by 'table_list')
So these methods were changed to reflect this.
Diffstat (limited to 'sql/item.h')
-rw-r--r-- | sql/item.h | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/sql/item.h b/sql/item.h index 63d89113ec1..7c6aa39cadf 100644 --- a/sql/item.h +++ b/sql/item.h @@ -337,23 +337,18 @@ public: { save_table_list= context->table_list; save_first_name_resolution_table= context->first_name_resolution_table; - save_next_name_resolution_table= (context->first_name_resolution_table) ? - context->first_name_resolution_table-> - next_name_resolution_table : - NULL; save_resolve_in_select_list= context->resolve_in_select_list; save_next_local= table_list->next_local; + save_next_name_resolution_table= table_list->next_name_resolution_table; } /* Restore a name resolution context from saved state. */ void restore_state(Name_resolution_context *context, TABLE_LIST *table_list) { table_list->next_local= save_next_local; + table_list->next_name_resolution_table= save_next_name_resolution_table; context->table_list= save_table_list; context->first_name_resolution_table= save_first_name_resolution_table; - if (context->first_name_resolution_table) - context->first_name_resolution_table-> - next_name_resolution_table= save_next_name_resolution_table; context->resolve_in_select_list= save_resolve_in_select_list; } }; |