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

Spider: Valid LEFT JOIN results in ERROR 1064

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 10.4.11, 10.5.11, 10.3(EOL)

    Description

      The following is a simplified version of my original query where the bug was first discovered. When attempting to do the following join of two Spider tables, the following error message is returned for a valid query:

      select nextID from tab1 LEFT join tab2 on id = currentID where id in ( 1 );
      

      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'join `forensic`.`tab2` t0 on (t0.`currentID` = 1 where 1' at line 1
      

      If I run the query on the back-end database instance, it works as expected with no error. If I run it on the Spider node instance, I get the 1064 error.

      I have tested this with Mariadb 10.4.11 and 10.5.11 (both with Spider version 3.3.15). I have also tested this with both tables as Innodb tables. The same error results.

      I have reduced the contents of my.cnf to the following for simplicity (but I've tested with and without these and they don't effect the result) and there are file path definitions that I define:

      log_warnings=1
      default_storage_engine=MyISAM
      innodb=OFF
      general_log=ON
      expire_logs_days=2
      

      create database mydb default character set latin1;
      use mydb
       
      create user spidy@`%`;
      set password for spidy@`%` = password('password123');
      grant select on *.* to spidy@`%`;
       
      -- grant all on mydb.tab1 to spidy@`%`;
      -- grant all on mydb.tab2 to spidy@`%`;
       
      create table tab1 (
        id int(4) not null auto_increment,
        status varchar(25) default null,
        primary key (id)
      ) engine=MYISAM default charset=latin1;
       
      create table tab2 (
        currentID int(4) not null default 0,
        nextID int(4) not null default 0,
        primary key (currentID, nextID)
      ) engine=MYISAM default charset=latin1;
       
      insert into tab1 values 
      (null, 'WORKING'),
      (null, 'READY FOR QC'),
      (null, 'READY TO CREATE'),
      (null, 'CREATED'),
      (null, 'APPROVAL ERROR'),
      (null, 'CREATION ERROR'),
      (null, 'AWAITING'),
      (null, 'NEEDS RTL'),
      (null, 'RTL SUBMITTED'),
      (null, 'ARCHIVED');
       
      insert into tab2 values 
      (1,2),
      (1,7),
      (1,8),
      (1,10),
      (2,6),
      (2,10),
      (3,4),
      (3,6),
      (3,10),
      (5,1),
      (5,10),
      (6,1),
      (6,10),
      (7,2),
      (7,10),
      (8,5),
      (8,9),
      (8,10),
      (9,2),
      (9,5),
      (9,7),
      (9,10),
      (10,1),
      (10,2),
      (10,3),
      (10,5),
      (10,6),
      (10,7),
      (10,8),
      (10,9);
       
      create or replace server dataNode1 foreign data wrapper mysql options (PORT 3306, HOST 'hostname', USER 'spidy', PASSWORD 'password123');
      select * from mysql.servers;
      select db_name, table_name, server from mysql.spider_tables;
       
      create table mydb.tab1 engine=SPIDER comment='wrapper "mysql", srv "dataNode1", table "tab1"';
      create table mydb.tab2 engine=SPIDER comment='wrapper "mysql", srv "dataNode1", table "tab2"';
       
      -- Test cases:
       
      -- produces ERROR
      select nextID 
      from tab1
      LEFT join tab2 on id = currentID
      where id in ( 1 );
       
      -- produces ERROR
      select nextID
      from tab2
      RIGHT join tab1 on currentID = id
      where id in ( 1 );
       
      -- produces ERROR
      select nextID
      from tab2
      RIGHT join tab1 on currentID = id
      where id in ( 1,2 );
       
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'join `forensic`.`tab2` t0 on (t0.`currentID` = 1 where 1' at line 1
       
      -- OK - no error
      select nextID 
      from tab1
      LEFT join tab2 on id = currentID
      where id in ( 1,2 );
       
      -- OK - no error
      select nextID 
      from tab2
      LEFT join tab1 on id = currentID
      where id in ( 1 );
       
      -- OK - no error
      select nextID
      from tab1
      RIGHT join tab2 on currentID = id
      where id in ( 1 );
      

      Attachments

        Issue Links

          Activity

            bgladhill Bob Gladhill created issue -
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Field Original Value New Value
            Fix Version/s 10.4 [ 22408 ]
            Fix Version/s 10.5 [ 23123 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Assignee Nayuta Yanagisawa [ JIRAUSER47117 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Description The following is a simplified version of my original query where the bug was first discovered. When attempting to do the following join of two Spider tables, the following error message is returned for a valid query:

            ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'join `forensic`.`tab2` t0 on (t0.`currentID` = 1 where 1' at line 1

            select nextID
            from tab1
            LEFT join tab2 on id = currentID
            where id in ( 1 );

            If I run the query on the back-end database instance, it works as expected with no error. If I run it on the Spider node instance, I get the 1064 error.

            I have tested this with Mariadb 10.4.11 and 10.5.11 (both with Spider version 3.3.15). I have also tested this with both tables as Innodb tables. The same error results.

            I have reduced the contents of my.cnf to the following for simplicity (but I've tested with and without these and they don't effect the result) and there are file path definitions that I define:

            log_warnings=1
            default_storage_engine=MyISAM
            innodb=OFF
            general_log=ON
            expire_logs_days=2


            create database mydb default character set latin1;
            use mydb

            create user spidy@`%`;
            set password for spidy@`%` = password('password123');
            grant select on *.* to spidy@`%`;

            -- grant all on mydb.tab1 to spidy@`%`;
            -- grant all on mydb.tab2 to spidy@`%`;

            create table tab1 (
              id int(4) not null auto_increment,
              status varchar(25) default null,
              primary key (id)
            ) engine=MYISAM default charset=latin1;

            create table tab2 (
              currentID int(4) not null default 0,
              nextID int(4) not null default 0,
              primary key (currentID, nextID)
            ) engine=MYISAM default charset=latin1;

            insert into tab1 values
            (null, 'WORKING'),
            (null, 'READY FOR QC'),
            (null, 'READY TO CREATE'),
            (null, 'CREATED'),
            (null, 'APPROVAL ERROR'),
            (null, 'CREATION ERROR'),
            (null, 'AWAITING'),
            (null, 'NEEDS RTL'),
            (null, 'RTL SUBMITTED'),
            (null, 'ARCHIVED');

            insert into tab2 values
            (1,2),
            (1,7),
            (1,8),
            (1,10),
            (2,6),
            (2,10),
            (3,4),
            (3,6),
            (3,10),
            (5,1),
            (5,10),
            (6,1),
            (6,10),
            (7,2),
            (7,10),
            (8,5),
            (8,9),
            (8,10),
            (9,2),
            (9,5),
            (9,7),
            (9,10),
            (10,1),
            (10,2),
            (10,3),
            (10,5),
            (10,6),
            (10,7),
            (10,8),
            (10,9);


            create or replace server dataNode1 foreign data wrapper mysql options (PORT 3306, HOST 'hostname', USER 'spidy', PASSWORD 'password123');
            select * from mysql.servers;
            select db_name, table_name, server from mysql.spider_tables;

            create table mydb.tab1 engine=SPIDER comment='wrapper "mysql", srv "dataNode1", table "tab1"';
            create table mydb.tab2 engine=SPIDER comment='wrapper "mysql", srv "dataNode1", table "tab2"';


            -- Test cases:

            -- produces ERROR
            select nextID
            from tab1
            LEFT join tab2 on id = currentID
            where id in ( 1 );

            -- produces ERROR
            select nextID
            from tab2
            RIGHT join tab1 on currentID = id
            where id in ( 1 );

            -- produces ERROR
            select nextID
            from tab2
            RIGHT join tab1 on currentID = id
            where id in ( 1,2 );


            ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'join `forensic`.`tab2` t0 on (t0.`currentID` = 1 where 1' at line 1


            -- OK - no error
            select nextID
            from tab1
            LEFT join tab2 on id = currentID
            where id in ( 1,2 );

            -- OK - no error
            select nextID
            from tab2
            LEFT join tab1 on id = currentID
            where id in ( 1 );

            -- OK - no error
            select nextID
            from tab1
            RIGHT join tab2 on currentID = id
            where id in ( 1 );
            The following is a simplified version of my original query where the bug was first discovered. When attempting to do the following join of two Spider tables, the following error message is returned for a valid query:

            {code:sql}
            select nextID from tab1 LEFT join tab2 on id = currentID where id in ( 1 );
            {code}

            {noformat}
            ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'join `forensic`.`tab2` t0 on (t0.`currentID` = 1 where 1' at line 1
            {noformat}

            If I run the query on the back-end database instance, it works as expected with no error. If I run it on the Spider node instance, I get the 1064 error.

            I have tested this with Mariadb 10.4.11 and 10.5.11 (both with Spider version 3.3.15). I have also tested this with both tables as Innodb tables. The same error results.

            I have reduced the contents of my.cnf to the following for simplicity (but I've tested with and without these and they don't effect the result) and there are file path definitions that I define:

            {noformat}
            log_warnings=1
            default_storage_engine=MyISAM
            innodb=OFF
            general_log=ON
            expire_logs_days=2
            {noformat}

            {code:sql}
            create database mydb default character set latin1;
            use mydb

            create user spidy@`%`;
            set password for spidy@`%` = password('password123');
            grant select on *.* to spidy@`%`;

            -- grant all on mydb.tab1 to spidy@`%`;
            -- grant all on mydb.tab2 to spidy@`%`;

            create table tab1 (
              id int(4) not null auto_increment,
              status varchar(25) default null,
              primary key (id)
            ) engine=MYISAM default charset=latin1;

            create table tab2 (
              currentID int(4) not null default 0,
              nextID int(4) not null default 0,
              primary key (currentID, nextID)
            ) engine=MYISAM default charset=latin1;

            insert into tab1 values
            (null, 'WORKING'),
            (null, 'READY FOR QC'),
            (null, 'READY TO CREATE'),
            (null, 'CREATED'),
            (null, 'APPROVAL ERROR'),
            (null, 'CREATION ERROR'),
            (null, 'AWAITING'),
            (null, 'NEEDS RTL'),
            (null, 'RTL SUBMITTED'),
            (null, 'ARCHIVED');

            insert into tab2 values
            (1,2),
            (1,7),
            (1,8),
            (1,10),
            (2,6),
            (2,10),
            (3,4),
            (3,6),
            (3,10),
            (5,1),
            (5,10),
            (6,1),
            (6,10),
            (7,2),
            (7,10),
            (8,5),
            (8,9),
            (8,10),
            (9,2),
            (9,5),
            (9,7),
            (9,10),
            (10,1),
            (10,2),
            (10,3),
            (10,5),
            (10,6),
            (10,7),
            (10,8),
            (10,9);

            create or replace server dataNode1 foreign data wrapper mysql options (PORT 3306, HOST 'hostname', USER 'spidy', PASSWORD 'password123');
            select * from mysql.servers;
            select db_name, table_name, server from mysql.spider_tables;

            create table mydb.tab1 engine=SPIDER comment='wrapper "mysql", srv "dataNode1", table "tab1"';
            create table mydb.tab2 engine=SPIDER comment='wrapper "mysql", srv "dataNode1", table "tab2"';

            -- Test cases:

            -- produces ERROR
            select nextID
            from tab1
            LEFT join tab2 on id = currentID
            where id in ( 1 );

            -- produces ERROR
            select nextID
            from tab2
            RIGHT join tab1 on currentID = id
            where id in ( 1 );

            -- produces ERROR
            select nextID
            from tab2
            RIGHT join tab1 on currentID = id
            where id in ( 1,2 );

            ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'join `forensic`.`tab2` t0 on (t0.`currentID` = 1 where 1' at line 1

            -- OK - no error
            select nextID
            from tab1
            LEFT join tab2 on id = currentID
            where id in ( 1,2 );

            -- OK - no error
            select nextID
            from tab2
            LEFT join tab1 on id = currentID
            where id in ( 1 );

            -- OK - no error
            select nextID
            from tab1
            RIGHT join tab2 on currentID = id
            where id in ( 1 );
            {code}
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Summary Valid Spider table query reports ERROR 1064 Spider: Valid LEFT JOIN results in ERROR 1064
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Labels 1064 join spider 1064 join not-10.2 spider
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Fix Version/s 10.3 [ 22126 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Fix Version/s 10.6 [ 24028 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Status Open [ 1 ] Confirmed [ 10101 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Status Confirmed [ 10101 ] In Progress [ 3 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Comment [ The cause of the bug is that the function {{spider_db_mbase_util::append_from_and_tables()}} place the table `tbl_a` in a wrong position of the query. ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Labels 1064 join not-10.2 spider 1064 join not-10.2 regression spider
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Status In Progress [ 3 ] Stalled [ 10000 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Labels 1064 join not-10.2 regression spider 1064 join not-10.2 spider
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Labels 1064 join not-10.2 spider 1064 not-10.2
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Affects Version/s 10.3 [ 22126 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Status Stalled [ 10000 ] In Progress [ 3 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Component/s Optimizer [ 10200 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 123883 ] MariaDB v4 [ 144607 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Status In Progress [ 3 ] Stalled [ 10000 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Status Stalled [ 10000 ] In Progress [ 3 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Fix Version/s 10.7 [ 24805 ]
            Fix Version/s 10.8 [ 26121 ]
            Fix Version/s 10.9 [ 26905 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Status In Progress [ 3 ] Stalled [ 10000 ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Status Stalled [ 10000 ] In Progress [ 3 ]
            Roel Roel Van de Paar made changes -
            ycp Yuchen Pei made changes -
            Assignee Nayuta Yanagisawa [ JIRAUSER47117 ] Yuchen Pei [ JIRAUSER52627 ]
            julien.fritsch Julien Fritsch made changes -
            Fix Version/s 10.7 [ 24805 ]
            julien.fritsch Julien Fritsch made changes -
            Fix Version/s 10.3 [ 22126 ]
            julien.fritsch Julien Fritsch made changes -
            Fix Version/s 10.8 [ 26121 ]
            ycp Yuchen Pei made changes -
            Priority Major [ 3 ] Critical [ 2 ]
            ycp Yuchen Pei made changes -
            Labels 1064 not-10.2 1064 not-10.2 spider-gbh
            ycp Yuchen Pei made changes -
            Status In Progress [ 3 ] Stalled [ 10000 ]
            ycp Yuchen Pei made changes -
            ycp Yuchen Pei made changes -
            ycp Yuchen Pei made changes -
            ycp Yuchen Pei made changes -
            ycp Yuchen Pei made changes -
            ycp Yuchen Pei made changes -
            ycp Yuchen Pei made changes -
            ycp Yuchen Pei made changes -
            ycp Yuchen Pei made changes -
            ycp Yuchen Pei made changes -
            Status Stalled [ 10000 ] In Progress [ 3 ]
            ycp Yuchen Pei made changes -
            Assignee Yuchen Pei [ JIRAUSER52627 ] Alexey Botchkov [ holyfoot ]
            Status In Progress [ 3 ] In Review [ 10002 ]
            ycp Yuchen Pei made changes -
            ycp Yuchen Pei made changes -
            ycp Yuchen Pei made changes -
            holyfoot Alexey Botchkov made changes -
            Assignee Alexey Botchkov [ holyfoot ] Yuchen Pei [ JIRAUSER52627 ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            ycp Yuchen Pei made changes -
            Assignee Yuchen Pei [ JIRAUSER52627 ] Alexey Botchkov [ holyfoot ]
            Status Stalled [ 10000 ] In Review [ 10002 ]
            holyfoot Alexey Botchkov made changes -
            Assignee Alexey Botchkov [ holyfoot ] Yuchen Pei [ JIRAUSER52627 ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            ycp Yuchen Pei made changes -
            Fix Version/s 10.4.33 [ 29516 ]
            Fix Version/s 10.4 [ 22408 ]
            Fix Version/s 10.5 [ 23123 ]
            Fix Version/s 10.6 [ 24028 ]
            Fix Version/s 10.9 [ 26905 ]
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]
            JIraAutomate JiraAutomate made changes -
            Fix Version/s 10.5.24 [ 29517 ]
            Fix Version/s 10.6.17 [ 29518 ]
            Fix Version/s 10.11.7 [ 29519 ]
            Fix Version/s 11.0.5 [ 29520 ]
            Fix Version/s 11.1.4 [ 29024 ]
            Fix Version/s 11.2.3 [ 29521 ]
            Richard Richard Stracke made changes -

            People

              ycp Yuchen Pei
              bgladhill Bob Gladhill
              Votes:
              1 Vote for this issue
              Watchers:
              11 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.