From d518f7020011b685f6753b1d86e9dd7a98a9c171 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 17 Nov 2005 03:51:14 +0300 Subject: Fix for bug #13399 Crash when executing PS/SP which should activate trigger which is now dropped" and bug #12329 "Bogus error msg when executing PS with stored procedure after SP was re-created". mysql-test/r/sp-error.result: Added test for bug #12329 "Bogus error msg when executing PS with stored procedure after SP was re-created". mysql-test/r/trigger.result: Added test for bug #13399 Crash when executing PS/SP which should activate trigger which is now dropped". mysql-test/t/sp-error.test: Added test for bug #12329 "Bogus error msg when executing PS with stored procedure after SP was re-created". mysql-test/t/trigger.test: Added test for bug #13399 Crash when executing PS/SP which should activate trigger which is now dropped". sql/sp_head.cc: sp_head::add_used_tables_to_table_list(): We have to copy database/table names and alias to PS/SP memory since current instance of sp_head object can pass away before next execution of PS/SP for which tables are added to prelocking list. This will be fixed by introducing of proper invalidation mechanism once new TDC is ready. --- sql/sp_head.cc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'sql/sp_head.cc') diff --git a/sql/sp_head.cc b/sql/sp_head.cc index e3cdc909048..6248a60521b 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -2906,33 +2906,34 @@ sp_head::add_used_tables_to_table_list(THD *thd, DBUG_ENTER("sp_head::add_used_tables_to_table_list"); /* - Use persistent arena for table list allocation to be PS friendly. + Use persistent arena for table list allocation to be PS/SP friendly. + Note that we also have to copy database/table names and alias to PS/SP + memory since current instance of sp_head object can pass away before + next execution of PS/SP for which tables are added to prelocking list. + This will be fixed by introducing of proper invalidation mechanism + once new TDC is ready. */ arena= thd->activate_stmt_arena_if_needed(&backup); for (i=0 ; i < m_sptabs.records ; i++) { - char *tab_buff; + char *tab_buff, *key_buff; TABLE_LIST *table; SP_TABLE *stab= (SP_TABLE *)hash_element(&m_sptabs, i); if (stab->temp) continue; if (!(tab_buff= (char *)thd->calloc(ALIGN_SIZE(sizeof(TABLE_LIST)) * - stab->lock_count))) + stab->lock_count)) || + !(key_buff= (char*)thd->memdup(stab->qname.str, + stab->qname.length + 1))) DBUG_RETURN(FALSE); for (uint j= 0; j < stab->lock_count; j++) { table= (TABLE_LIST *)tab_buff; - /* - It's enough to just copy the pointers as the data will not change - during the lifetime of the SP. If the SP is used by PS, we assume - that the PS will be invalidated if the functions is deleted or - changed. - */ - table->db= stab->qname.str; + table->db= key_buff; table->db_length= stab->db_length; table->table_name= table->db + table->db_length + 1; table->table_name_length= stab->table_name_length; -- cgit v1.2.1