• kroki/tomash@moonlight.home's avatar
    BUG#9953: CONVERT_TZ requires mysql.time_zone_name to be locked · c19affef
    kroki/tomash@moonlight.home authored
    The problem was that some facilities (like CONVERT_TZ() function or
    server HELP statement) may require implicit access to some tables in
    'mysql' database.  This access was done by ordinary means of adding
    such tables to the list of tables the query is going to open.
    However, if we issued LOCK TABLES before that, we would get "table
    was not locked" error trying to open such implicit tables.
    
    The solution is to treat certain tables as MySQL system tables, like
    we already do for mysql.proc.  Such tables may be opened for reading
    at any moment regardless of any locks in effect.  The cost of this is
    that system table may be locked for writing only together with other
    system tables, it is disallowed to lock system tables for writing and
    have any other lock on any other table.
    
    After this patch the following tables are treated as MySQL system
    tables:
      mysql.help_category
      mysql.help_keyword
      mysql.help_relation
      mysql.help_topic
      mysql.proc (it already was)
      mysql.time_zone
      mysql.time_zone_leap_second
      mysql.time_zone_name
      mysql.time_zone_transition
      mysql.time_zone_transition_type
    
    These tables are now opened with open_system_tables_for_read() and
    closed with close_system_tables(), or one table may be opened with
    open_system_table_for_update() and closed with close_thread_tables()
    (the latter is used for mysql.proc table, which is updated as part of
    normal MySQL server operation).  These functions may be used when
    some tables were opened and locked already.
    
    NOTE: online update of time zone tables is not possible during
    replication, because there's no time zone cache flush neither on LOCK
    TABLES, nor on FLUSH TABLES, so the master may serve stale time zone
    data from cache, while on slave updated data will be loaded from the
    time zone tables.
    c19affef
ha_myisam.cc 58.5 KB