1
0
mirror of https://github.com/MariaDB/server.git synced 2025-09-02 09:41:40 +03:00

A fix for Bug#5748 "Prepared statement with BETWEEN and bigint values

crashes mysqld": implementation for a generic item tree modifications
registry. Every item tree modification which should be rolled back for
subsequent execution of a prepared statement or stored procedure should
be saved in the registry. All such modifications are rolled back at once
during cleanup stage of PS.
Actual fix for the bug just adds a call to register modifications to
convert_constant_item.
Post review fixes implemented.
This commit is contained in:
konstantin@mysql.com
2004-10-08 02:21:19 +04:00
parent 66923bf968
commit 2aa7ec0d9d
10 changed files with 127 additions and 26 deletions

View File

@@ -698,6 +698,54 @@ void THD::close_active_vio()
#endif
struct Item_change_record: public ilink
{
Item **place;
Item *old_value;
/* Placement new was hidden by `new' in ilink (TODO: check): */
static void *operator new(unsigned int size, void *mem) { return mem; }
};
/*
Register an item tree tree transformation, performed by the query
optimizer. We need a pointer to runtime_memroot because it may be !=
thd->mem_root (due to possible set_n_backup_item_arena called for thd).
*/
void THD::nocheck_register_item_tree_change(Item **place, Item *old_value,
MEM_ROOT *runtime_memroot)
{
Item_change_record *change;
/*
Now we use one node per change, which adds some memory overhead,
but still is rather fast as we use alloc_root for allocations.
A list of item tree changes of an average query should be short.
*/
void *change_mem= alloc_root(runtime_memroot, sizeof(*change));
if (change_mem == 0)
{
fatal_error();
return;
}
change= new (change_mem) Item_change_record;
change->place= place;
change->old_value= old_value;
change_list.push_back(change);
}
void THD::rollback_item_tree_changes()
{
I_List_iterator<Item_change_record> it(change_list);
Item_change_record *change;
while ((change= it++))
*change->place= change->old_value;
/* We can forget about changes memory: it's allocated in runtime memroot */
change_list.empty();
}
/*****************************************************************************
** Functions to provide a interface to select results
*****************************************************************************/