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

Wrong result on 2nd execution of PS for query with derived table

Details

    Description

      Testcase:

      --source have_federatedx.inc
      --source include/federated.inc
       
      connection default;
      set global federated_pushdown=1;
       
      connection slave;
      DROP TABLE IF EXISTS federated.t1;
      CREATE TABLE federated.t1 (
        id int(20) NOT NULL,
        name varchar(16) NOT NULL default ''
      )
      DEFAULT CHARSET=latin1;
      INSERT INTO federated.t1 VALUES
        (3,'xxx'), (7,'yyy'), (4,'xxx'), (1,'zzz'), (5,'yyy');
       
      connection master;
      DROP TABLE IF EXISTS federated.t1;
      --replace_result $SLAVE_MYPORT SLAVE_PORT
      eval
      CREATE TABLE federated.t1 (
        id int(20) NOT NULL,
        name varchar(16) NOT NULL default ''
      )
      ENGINE="FEDERATED" DEFAULT CHARSET=latin1
      CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1';
       
      CREATE TABLE federated.t3 (
        name varchar(16) NOT NULL default ''
      )
      DEFAULT CHARSET=latin1;
      INSERT INTO federated.t3 VALUES
        ('yyy'), ('www'), ('yyy'), ('xxx'), ('www'), ('yyy'), ('www');
       
      SELECT *
      FROM federated.t3, (SELECT * FROM federated.t1 WHERE id > 3) t
      WHERE federated.t3.name=t.name;
       
      prepare stmt from 'SELECT *
      FROM federated.t3, (SELECT * FROM federated.t1 WHERE id > 3) t
      WHERE federated.t3.name=t.name';
      execute stmt;
      execute stmt;
      deallocate prepare stmt;
       
      set global federated_pushdown=0;
      source include/federated_cleanup.inc;
      

      Actual result:

      execute stmt;
      name	id	name
      yyy	5	yyy
      yyy	7	yyy
      yyy	5	yyy
      yyy	7	yyy
      xxx	4	xxx
      yyy	5	yyy
      yyy	7	yyy
      execute stmt;
      name	id	name
      yyy	0	
      yyy	0	
      yyy	0	
      yyy	0	
      xxx	0	
      yyy	0	
      yyy	0	
      

      Expected result:

      execute stmt;
      name	id	name
      yyy	5	yyy
      yyy	7	yyy
      yyy	5	yyy
      yyy	7	yyy
      xxx	4	xxx
      yyy	5	yyy
      yyy	7	yyy
      execute stmt;
      name	id	name
      yyy	5	yyy
      yyy	7	yyy
      yyy	5	yyy
      yyy	7	yyy
      xxx	4	xxx
      yyy	5	yyy
      yyy	7	yyy
      

      Attachments

        Issue Links

          Activity

            Assigned it to myself

            igor Igor Babaev (Inactive) added a comment - Assigned it to myself

            OK to push a8217d7213a0d8c6faebfb50bdc839a53c7cf21b

            sanja Oleksandr Byelkin added a comment - OK to push a8217d7213a0d8c6faebfb50bdc839a53c7cf21b

            A fix for this bug was pushed into 10.5. It should be merged upstream as it is.

            igor Igor Babaev (Inactive) added a comment - A fix for this bug was pushed into 10.5. It should be merged upstream as it is.

            I noticed that the following section in the file mysql-test/suite/federated/federatedx_create_handlers.test was not adjusted or removed:

            #Check after fix MDEV-31361
            --disable_ps2_protocol
            SELECT *
            FROM federated.t3, (SELECT t1.name FROM federated.t1
                                WHERE id IN (SELECT count(*)
                                             FROM federated.t2 GROUP BY name)) t
            WHERE federated.t3.name=t.name;
            --enable_ps2_protocol
            

            marko Marko Mäkelä added a comment - I noticed that the following section in the file mysql-test/suite/federated/federatedx_create_handlers.test was not adjusted or removed: # Check after fix MDEV-31361 --disable_ps2_protocol SELECT * FROM federated.t3, ( SELECT t1. name FROM federated.t1 WHERE id IN ( SELECT count (*) FROM federated.t2 GROUP BY name )) t WHERE federated.t3. name =t. name ; --enable_ps2_protocol

            On my attempt to merge this to 11.1, the results in this file had to be adjusted as follows:

            diff --git a/mysql-test/suite/federated/federatedx_create_handlers.result b/mysql-test/suite/federated/federatedx_create_handlers.result
            index 1d6aa5d0f9b..698dfab9449 100644
            --- a/mysql-test/suite/federated/federatedx_create_handlers.result
            +++ b/mysql-test/suite/federated/federatedx_create_handlers.result
            @@ -551,8 +551,7 @@ EXPLAIN
             SELECT * FROM (SELECT * FROM (SELECT * FROM (SELECT * FROM t1 where id=3) dt3
             WHERE id=3) dt2) dt;
             id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
            -1	PRIMARY	<derived4>	ALL	NULL	NULL	NULL	NULL	5	Using where
            -4	PUSHED DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
            +1	PUSHED SELECT	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
             connection slave;
             CREATE TABLE federated.t10 (a INT,b INT);
             CREATE TABLE federated.t11 (a INT, b INT);
            

            marko Marko Mäkelä added a comment - On my attempt to merge this to 11.1 , the results in this file had to be adjusted as follows: diff --git a/mysql-test/suite/federated/federatedx_create_handlers.result b/mysql-test/suite/federated/federatedx_create_handlers.result index 1d6aa5d0f9b..698dfab9449 100644 --- a/mysql-test/suite/federated/federatedx_create_handlers.result +++ b/mysql-test/suite/federated/federatedx_create_handlers.result @@ -551,8 +551,7 @@ EXPLAIN SELECT * FROM (SELECT * FROM (SELECT * FROM (SELECT * FROM t1 where id=3) dt3 WHERE id=3) dt2) dt; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY <derived4> ALL NULL NULL NULL NULL 5 Using where -4 PUSHED DERIVED NULL NULL NULL NULL NULL NULL NULL NULL +1 PUSHED SELECT NULL NULL NULL NULL NULL NULL NULL NULL connection slave; CREATE TABLE federated.t10 (a INT,b INT); CREATE TABLE federated.t11 (a INT, b INT);

            People

              igor Igor Babaev (Inactive)
              lstartseva Lena Startseva
              Votes:
              0 Vote for this issue
              Watchers:
              7 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.