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

mariadb-tzinfo-to-sql creates sql_mode dependant statements

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

            croser Christian Roser created issue -
            croser Christian Roser made changes -
            Field Original Value New Value
            Affects Version/s 10.6 [ 24028 ]
            Affects Version/s 10.11 [ 27614 ]
            Affects Version/s 10.6.12 [ 28513 ]
            Affects Version/s 10.11.2 [ 28523 ]
            dlenski Daniel Lenski (Inactive) made changes -

            Closely related to MDEV-18778 , MDEV-28263, and MDEV-28782.

            The common feature: there's a lack of testing of whether or not the generated timezone.sql actually works in different build and execution environments.

            dlenski Daniel Lenski (Inactive) added a comment - Closely related to MDEV-18778 , MDEV-28263 , and MDEV-28782 . The common feature: there's a lack of testing of whether or not the generated timezone.sql actually works in different build and execution environments.
            dlenski Daniel Lenski (Inactive) made changes -
            dlenski Daniel Lenski (Inactive) made changes -
            dlenski Daniel Lenski (Inactive) added a comment - This bug (using " in the generated timezone SQL) was introduced by danblack in https://github.com/MariaDB/server/commit/13e77930e615f05cc74d408110e887b00e1abcc9#diff-a333d4ebb2d73b6361ef7dfebc86d883f7e19853b4a9eb85984b039058fae47cR2431-R2435
            dlenski Daniel Lenski (Inactive) added a comment - PR to fix this issue: https://github.com/MariaDB/server/pull/2604
            dlenski Daniel Lenski (Inactive) made changes -
            danblack Daniel Black made changes -
            Assignee Daniel Black [ danblack ]
            danblack Daniel Black added a comment -

            thanks dlenski!

            danblack Daniel Black added a comment - thanks dlenski !
            danblack Daniel Black made changes -
            Fix Version/s 10.6.13 [ 28514 ]
            Fix Version/s 10.9.6 [ 28520 ]
            Fix Version/s 10.10.4 [ 28522 ]
            Fix Version/s 10.11.3 [ 28524 ]
            Fix Version/s 11.1.1 [ 28704 ]
            Fix Version/s 10.8.8 [ 28518 ]
            Fix Version/s 11.0.2 [ 28706 ]
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Closed [ 6 ]

            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.