Uploaded image for project: 'MariaDB MaxScale'
  1. MariaDB MaxScale
  2. MXS-957

Temporary table creation from another temporary table isn't detected

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.0.2
    • Component/s: readwritesplit
    • Labels:
      None

      Description

      When the following SQL is executed through readwritesplit, the last statement fails because it is routed to a slave instead of the master.

      CREATE OR REPLACE TABLE t1(`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY);
      CREATE OR REPLACE TABLE t2(`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY);
      CREATE TEMPORARY TABLE temp1(`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY);
      INSERT INTO temp1 values (1), (2), (3);
      INSERT INTO t1 values (1), (2), (3);
      INSERT INTO t2 values (1), (2), (3);
      CREATE TEMPORARY TABLE temp2 SELECT DISTINCT p.id FROM temp1 p JOIN t1 t ON (t.id = p.id) LEFT JOIN t2 ON (t.id = t2.id) WHERE p.id IS NOT NULL AND @@server_id IS NOT NULL;
      SELECT * FROM temp2;
      

      This is caused by the following code in readwritesplit.c which replaces the query type instead of amending to the value.

              /**
               * Check if the query has anything to do with temporary tables.
               */
              if (rses->have_tmp_tables &&
                  (packet_type == MYSQL_COM_QUERY || packet_type == MYSQL_COM_DROP_DB))
              {
                  check_drop_tmp_table(rses, querybuf, qtype);
                  if (packet_type == MYSQL_COM_QUERY)
                  {
                      qtype = is_read_tmp_table(rses, querybuf, qtype);
                  }
              }
              check_create_tmp_table(rses, querybuf, qtype);
      

        Attachments

          Activity

            People

            Assignee:
            markus makela markus makela
            Reporter:
            markus makela markus makela
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration