1
0
mirror of https://github.com/MariaDB/server.git synced 2025-05-27 01:57:48 +03:00
unknown 1dead07d14 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.
2007-01-23 15:03:48 +03:00
..
2006-05-29 16:27:45 +02:00
2006-06-17 02:57:50 +04:00
2006-07-13 20:48:26 -07:00
2006-05-31 22:55:45 -07:00
2006-10-13 08:48:47 +02:00
2006-06-15 01:48:41 +04:00
2006-11-06 23:02:40 -05:00
2006-05-16 22:19:44 -07:00
2006-09-01 05:00:32 +02:00
2006-10-05 00:00:34 +02:00
2006-08-08 12:50:05 +05:00
2006-10-03 15:48:41 +02:00
2006-05-31 22:55:45 -07:00
2006-11-17 12:02:36 +04:00
2006-05-31 22:55:45 -07:00
2006-10-19 18:48:37 +05:00
2006-04-27 21:59:04 +09:30
2006-06-01 16:51:19 -07:00
2006-06-01 16:51:19 -07:00
2006-06-30 02:03:09 +04:00
2006-06-09 19:29:39 -07:00
2006-03-31 21:26:17 -08:00