|
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);
|
|