mirror of
https://github.com/MariaDB/server.git
synced 2026-04-28 11:15:33 +02:00
Bug#16461: connection_id() does not work properly inside trigger
CONNECTION_ID() was implemented as a constant Item, i.e. an instance of Item_static_int_func class holding value computed at creation time. Since Items are created on parsing, and trigger statements are parsed on table open, the first connection to open a particular table would effectively set its own CONNECTION_ID() inside trigger statements for that table. Re-implement CONNECTION_ID() as a class derived from Item_int_func, and compute connection_id on every call to fix_fields(). mysql-test/r/trigger.result: Add result for bug#16461. mysql-test/t/trigger.test: Add test case for bug#16461. sql/item.cc: Remove now unused class Item_static_int_func. sql/item.h: Remove now unused class Item_static_int_func. sql/item_create.cc: Use new implementation of CONNECTION_ID(). sql/item_func.cc: Re-implement CONNECTION_ID() as Item_func_connection_id (was Item_static_int_func). Set max_length to 10, as it was before. Compute connection_id dynamically on every call to fix_fields(). sql/item_func.h: Re-implement CONNECTION_ID() as Item_func_connection_id (was Item_static_int_func).
This commit is contained in:
parent
daac388624
commit
886a35bd82
7 changed files with 80 additions and 36 deletions
|
|
@ -71,14 +71,8 @@ Item *create_func_ceiling(Item* a)
|
|||
|
||||
Item *create_func_connection_id(void)
|
||||
{
|
||||
THD *thd=current_thd;
|
||||
thd->lex->safe_to_cache_query= 0;
|
||||
return new Item_static_int_func("connection_id()",
|
||||
(longlong)
|
||||
((thd->slave_thread) ?
|
||||
thd->variables.pseudo_thread_id :
|
||||
thd->thread_id),
|
||||
10);
|
||||
current_thd->lex->safe_to_cache_query= 0;
|
||||
return new Item_func_connection_id();
|
||||
}
|
||||
|
||||
Item *create_func_conv(Item* a, Item *b, Item *c)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue