• unknown's avatar
    Fix for bug#11081 "Using a CONVERT_TZ function in a stored function or · dfbf6521
    unknown authored
    trigger fails".
    
    In cases when CONVERT_TZ() function was used in trigger or stored function
    (or in stored procedure which was called from trigger or stored function)
    error about non existing '.' table was reported.
    
    Statements that use CONVERT_TZ() function should have time zone related
    tables in their table list. tz_init_table_list() function which is used
    to produce part of table list containing those tables didn't set
    TABLE_LIST::db_length/table_name_length members properly. As result time
    zone tables needed for CONVERT_TZ() function were incorrectly handled by
    prelocking algorithm and "Table '.' doesn't exist' error was emitted.
    This fix changes tz_init_table_list() in such way that it properly inits
    TABLE_LIST::table_name_length/db_length members and thus produces table list
    which can be handled by prelocking algorithm correctly.
    
    
    mysql-test/r/timezone2.result:
      Added test for bug #11081 "Using a CONVERT_TZ function in a stored function
      or trigger fails".
    mysql-test/t/timezone2.test:
      Added test for bug #11081 "Using a CONVERT_TZ function in a stored function
      or trigger fails".
    sql/tztime.cc:
      Now tz_init_table_list() inits table_name_length and db_length members in
      TABLE_LIST objects, so table lists produced with its help can be handled 
      by prelocking algorithm properly.
      
      Also two clean-ups are included:
      - Now we use MY_TZ_TABLES_COUNT instead of magical number 4 in places where
        it is appropriate.
      - TZ_NAMES_ENTRY structure was converted to Tz_names_entry class in order 
        to emphasize its non-POD nature.
    sql/tztime.h:
      Added MY_TZ_TABLES_COUNT constant to be used as number of time zone related
      tables which are needed for dynamical loading of time zone descriptions.
    dfbf6521
timezone2.result 10.1 KB