Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-30854

mariadb-tzinfo-to-sql creates sql_mode dependant statements

    XMLWordPrintable

Details

    Description

      Hi,

      it looks like mariadb-tzinfo-to-sql generates some sql statements that only run under certain conditions:

      empty sql_mode, working fine:

      mysql@host[~](test)> mysql -BN -e "set @@global.sql_mode = ''"
      mysql@host[~](test)> mariadb-tzinfo-to-sql /usr/share/zoneinfo/ | mysql mysql
      mysql@host[~](test)> 
      

      mysql@host[~](test)> mysql -BN -e "set @@global.sql_mode = 'ansi_quotes'"
      mysql@host[~](test)> mariadb-tzinfo-to-sql /usr/share/zoneinfo/ | mysql -f mysql
      ERROR 1054 (42S22) at line 4: Unknown column 'select ENGINE into @time_zone_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone'' in 'field list'
      ERROR 1054 (42S22) at line 6: Unknown column 'select ENGINE into @time_zone_name_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_name'' in 'field list'
      ERROR 1054 (42S22) at line 8: Unknown column 'select ENGINE into @time_zone_transition_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_transition'' in 'field list'
      ERROR 1054 (42S22) at line 10: Unknown column 'select ENGINE into @time_zone_transition_type_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_transition_type'' in 'field list'
      

      statements that cause the issue have double quotes in line 5,7,9,11

      1
      mysql@host[~](test)> mariadb-tzinfo-to-sql /usr/share/zoneinfo/ | head -12
      2
      set @wsrep_is_on=(select coalesce(sum(SESSION_VALUE='ON'), 0) from information_schema.SYSTEM_VARIABLES WHERE VARIABLE_NAME='wsrep_on');
      3
      SET STATEMENT SQL_MODE='' FOR SELECT concat('%', GROUP_CONCAT(OPTION), '%') INTO @replicate_opt  FROM   (SELECT DISTINCT concat('REPLICATE_', UPPER(ENGINE)) AS OPTION    FROM information_schema.TABLES    WHERE TABLE_SCHEMA=DATABASE()      AND TABLE_NAME IN ('time_zone',                         'time_zone_name',                         'time_zone_transition',                         'time_zone_transition_type',                         'time_zone_leap_second')      AND ENGINE in ('MyISAM',                     'Aria')) AS o ORDER BY OPTION DESC;
      4
      set @wsrep_cannot_replicate_tz=@wsrep_is_on AND (select coalesce(sum(GLOBAL_VALUE NOT LIKE @replicate_opt), 0) from information_schema.SYSTEM_VARIABLES WHERE VARIABLE_NAME='wsrep_mode');
      5
      execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone'", 'do 0');
      6
      execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone ENGINE=InnoDB', 'do 0');
      7
      execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_name_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_name'", 'do 0');
      8
      execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_name ENGINE=InnoDB', 'do 0');
      9
      execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_transition_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_transition'", 'do 0');
      10
      execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_transition ENGINE=InnoDB', 'do 0');
      11
      execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_transition_type_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_transition_type'", 'do 0');
      12
      execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_transition_type ENGINE=InnoDB', 'do 0');
      13
      TRUNCATE TABLE time_zone;
      

      Attachments

        Issue Links

          Activity

            People

              danblack Daniel Black
              croser Christian Roser
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.