1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Fix for bug #7899 "CREATE TABLE .. SELECT .. and CONVERT_TZ() function

does not work well together". Now using simplier and more correct
implementation of st_lex::unlink_first_table()/link_first_table_back() 
(It also nicely handles case when global table list is created because
of implictly used time zone tables). (2nd attempt)

Fix for bug #7705 "CONVERT_TZ() crashes with subquery/WHERE on index
column". Implemented new approach for caching objects for constant
time zone arguments. Now instead of determining whenever these arguments
are constants and performing time zone lookup at fix_fields() stage, we
do it on first get_date() invocation.

Cleanup of global @@time_zone variable handling.


mysql-test/r/timezone2.result:
  Added test for bugs #7705 "CONVERT_TZ() crashes with subquery/WHERE on
  index column" and #7899 "CREATE TABLE .. SELECT .. and CONVERT_TZ()
  function does not work well together".
mysql-test/t/timezone2.test:
  Added test for bugs #7705 "CONVERT_TZ() crashes with subquery/WHERE on
  index column" and #7899 "CREATE TABLE .. SELECT .. and CONVERT_TZ()
  function does not work well together".
sql/item_timefunc.cc:
  Item_func_convert_tz():
    New approach for caching objects for constant time zone arguments.
    Now instead of determining whenever these arguments are constants
    and performing time zone lookup at fix_fields() stage, we do it
    on first get_date() invocation. This works better in cases when 
    const_item() for these arguments returns true only on get_date()
    stage but not on fix_fields() stage (e.g. this happens in quries
    with joins or derived tables).
sql/item_timefunc.h:
  Item_func_convert_tz():
    Added from_tz_cached/to_tz_cached members indicating whenever we
    already have Time_zone object representing one of constant time zone
    arguments.
sql/set_var.cc:
  Cleaned up global @@time_zone variable handling. Now we use proper
  locking when we are setting or reading its value.
sql/set_var.h:
  Removed declaration of sys_var_thd_time_zone::get_tz_ptr() method, which
  no longer used.
sql/sql_lex.cc:
  st_lex::unlink_first_table(), st_lex::link_first_table_back():
   Simplify implementation according to Monty's suggestion.
   Instead doing something special if global and local table lists
   are the same, we simply save/restore pointers to first elements
   of both global and local lists (which works even when this lists
   are the same!). This handles nicely the case when we have separate
   global table list becuase time zone tables are implicitly used.
sql/tztime.cc:
  Backport of Monty's fixes from 5.0, which give us nicer error messages
  if we haven't found time zone with such name or its description.
This commit is contained in:
unknown
2005-01-26 22:25:02 +03:00
parent e8e4861401
commit 20bd0bd6fd
8 changed files with 88 additions and 49 deletions

View File

@ -1719,8 +1719,8 @@ st_lex::st_lex()
global_first Save first global table here
local_first Save first local table here
NORES
global_first & local_first are used to save result for link_first_table_back
NOTES
This function assumes that outer select list is non-empty.
RETURN
global list without first table
@ -1730,25 +1730,25 @@ TABLE_LIST *st_lex::unlink_first_table(TABLE_LIST *tables,
TABLE_LIST **global_first,
TABLE_LIST **local_first)
{
DBUG_ASSERT(select_lex.table_list.first != 0);
/*
Save pointers to first elements of global table list and list
of tables used in outer select. It does not harm if these lists
are the same.
*/
*global_first= tables;
*local_first= (TABLE_LIST*)select_lex.table_list.first;
/*
Exclude from global table list
*/
/* Exclude first elements from these lists */
select_lex.table_list.first= (byte*) (*local_first)->next;
tables= tables->next;
/*
and from local list if it is not the same
*/
select_lex.table_list.first= ((&select_lex != all_selects_list) ?
(byte*) (*local_first)->next :
(byte*) tables);
(*global_first)->next= 0;
return tables;
}
/*
Link table back that was unlinked with unlink_first_table()
Link table which was unlinked with unlink_first_table() back.
SYNOPSIS
link_first_table_back()
@ -1764,16 +1764,7 @@ TABLE_LIST *st_lex::link_first_table_back(TABLE_LIST *tables,
TABLE_LIST *local_first)
{
global_first->next= tables;
if (&select_lex != all_selects_list)
{
/*
we do not touch local table 'next' field => we need just
put the table in the list
*/
select_lex.table_list.first= (byte*) local_first;
}
else
select_lex.table_list.first= (byte*) global_first;
select_lex.table_list.first= (byte*) local_first;
return global_first;
}