Commit e39eb182 authored by Jacob Mathew's avatar Jacob Mathew

MDEV-16398: Spider Creates Query With Non-Existent Function

The problem occurs because the statement generated by Spider used an
internal function name, ADD_TIME.

This problem has been corrected by the fix for bug MDEV-16878 within the
server, which enables Spider to generate the statement using the actual
SQL function name.  I have made some additional changes within Spider to fix
related problems that I observed while testing.

Author:
  Jacob Mathew.

First Reviewer:
  Alexander Barkov.

Second Reviewer:
  Kentoku Shiba.

Cherry-Picked:
  Commit 4b6dccc8 on branch bb-10.3-MDEV-16398
parent f6d4f624
......@@ -250,7 +250,7 @@ if (`SELECT IF($PLUGIN_VERSION = 3, 1, 0)`)
format_id int not null default 0,
gtrid_length int not null default 0,
bqual_length int not null default 0,
data char(128) charset binary not null default '',
data binary(128) not null default '',
status char(8) not null default '',
PRIMARY KEY (data, format_id, gtrid_length),
KEY idx1 (status)
......@@ -260,7 +260,7 @@ if (`SELECT IF($PLUGIN_VERSION = 3, 1, 0)`)
format_id int not null default 0,
gtrid_length int not null default 0,
bqual_length int not null default 0,
data char(128) charset binary not null default '',
data binary(128) not null default '',
scheme char(64) not null default '',
host char(64) not null default '',
port char(5) not null default '',
......@@ -282,7 +282,7 @@ if (`SELECT IF($PLUGIN_VERSION = 3, 1, 0)`)
format_id int not null default 0,
gtrid_length int not null default 0,
bqual_length int not null default 0,
data char(128) charset binary not null default '',
data binary(128) not null default '',
scheme char(64) not null default '',
host char(64) not null default '',
port char(5) not null default '',
......@@ -337,8 +337,8 @@ if (`SELECT IF($PLUGIN_VERSION = 3, 1, 0)`)
CREATE TABLE mysql.spider_link_mon_servers(
db_name char(64) not null default '',
table_name char(199) not null default '',
link_id char(5) not null default '',
sid int not null default 0,
link_id char(64) not null default '',
sid int unsigned not null default 0,
server char(64) default null,
scheme char(64) default null,
host char(64) default null,
......@@ -360,7 +360,7 @@ if (`SELECT IF($PLUGIN_VERSION = 3, 1, 0)`)
CREATE TABLE mysql.spider_link_failed_log(
db_name char(64) not null default '',
table_name char(199) not null default '',
link_id int not null default 0,
link_id char(64) not null default '',
failed_time timestamp not null default current_timestamp
) ENGINE=MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS mysql.spider_table_position_for_recovery;
......
......@@ -154,7 +154,7 @@ col_a col_b col_c
connection child2_1;
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
argument
select `col_a`,`col_b`,`col_c` from `auto_test_remote`.`tbl_a`
select t0.`col_a` `col_a`,t0.`col_b` `col_b`,t0.`col_c` `col_c` from `auto_test_remote`.`tbl_a` t0
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'
SELECT col_a, col_b, col_c FROM tbl_a ORDER BY col_a;
col_a col_b col_c
......
......@@ -40,8 +40,10 @@ SELECT 1;
create table
connection child2_1;
CHILD2_1_DROP_TABLES
CHILD2_1_CREATE_TABLES
CHILD2_1_DROP_TABLE
CHILD2_1_DROP_TABLE_F
CHILD2_1_CREATE_TABLE
CHILD2_1_CREATE_TABLE_F
TRUNCATE TABLE mysql.general_log;
connection master_1;
DROP TABLE IF EXISTS tbl_a;
......@@ -51,7 +53,12 @@ col_dt DATETIME,
col_ts TIMESTAMP NOT NULL
DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY(col_a),
UNIQUE INDEX i_ts (col_ts)
) MASTER_1_ENGINE MASTER_1_AUTO_INCREMENT_2_1 MASTER_1_COMMENT_2_1
CREATE TABLE tbl_f (
col_d DATE,
col_t TIME
) ENGINE=Spider COMMENT='database "ts_test_remote", table "tbl_f", srv "s_2_1"'
SHOW CREATE TABLE tbl_a;
Table Create Table
tbl_a CREATE TABLE `tbl_a` (
......@@ -61,6 +68,12 @@ tbl_a CREATE TABLE `tbl_a` (
PRIMARY KEY (`col_a`),
UNIQUE KEY `i_ts` (`col_ts`)
) ENGINE=SPIDER AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COMMENT='database "ts_test_remote", table "tbl_a", srv "s_2_1"'
SHOW CREATE TABLE tbl_f;
Table Create Table
tbl_f CREATE TABLE `tbl_f` (
`col_d` date DEFAULT NULL,
`col_t` time DEFAULT NULL
) ENGINE=SPIDER DEFAULT CHARSET=latin1 COMMENT='database "ts_test_remote", table "tbl_f", srv "s_2_1"'
Set a different time zone that has DST
SET time_zone='+01:00';
......@@ -101,7 +114,7 @@ col_a col_dt col_ts unix_timestamp(col_ts)
connection child2_1;
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
argument
select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a`
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'
SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a;
col_a col_dt col_ts unix_timestamp(col_ts)
......@@ -127,7 +140,7 @@ col_a col_dt col_ts unix_timestamp(col_ts)
connection child2_1;
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
argument
select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a`
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'
SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a;
col_a col_dt col_ts unix_timestamp(col_ts)
......@@ -153,7 +166,7 @@ col_a col_dt col_ts unix_timestamp(col_ts)
connection child2_1;
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
argument
select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a`
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'
SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a;
col_a col_dt col_ts unix_timestamp(col_ts)
......@@ -181,7 +194,7 @@ connection child2_1;
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
argument
select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` for update
select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a`
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'
SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a;
col_a col_dt col_ts unix_timestamp(col_ts)
......@@ -239,13 +252,13 @@ col_a col_dt col_ts unix_timestamp(col_ts)
connection child2_1;
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
argument
select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where (`col_ts` > '2017-12-31 23:00:00') order by `col_ts`
select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where (`col_ts` < '2018-10-28 01:30:00') order by `col_ts`
select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where ('2018-10-28 01:30:00' > `col_ts`) order by `col_ts`
select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where `col_ts` >= '2018-10-28 00:30:00' and `col_ts` <= '2018-10-28 01:30:00' and (`col_ts` between '2018-10-28 00:30:00' and '2018-10-28 01:30:00') order by `col_ts`
select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where `col_ts` >= '2018-10-28 00:30:00' and `col_ts` <= '2018-10-28 01:30:00' and ((`col_ts` >= '2018-10-28 00:30:00') and (`col_ts` <= '2018-10-28 01:30:00')) order by `col_ts`
select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where (`col_ts` > '2018-03-25 01:00:00') order by `col_ts`
select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where (`col_ts` > '1970-01-01 00:00:01') order by `col_ts`
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > '2017-12-31 23:00:00')
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` < '2018-10-28 01:30:00')
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where ('2018-10-28 01:30:00' > t0.`col_ts`)
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` between '2018-10-28 00:30:00' and '2018-10-28 01:30:00')
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where ((t0.`col_ts` >= '2018-10-28 00:30:00') and (t0.`col_ts` <= '2018-10-28 01:30:00'))
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > '2018-03-25 01:00:00')
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > '1970-01-01 00:00:01')
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'
SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a;
col_a col_dt col_ts unix_timestamp(col_ts)
......@@ -326,13 +339,13 @@ col_a col_dt col_ts unix_timestamp(col_ts)
connection child2_1;
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
argument
select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where (`col_ts` > '2017-12-31 23:00:00')
select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where (`col_ts` < '2018-10-28 01:30:00')
select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where ('2018-10-28 01:30:00' > `col_ts`)
select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where (`col_ts` between '2018-10-28 00:30:00' and '2018-10-28 01:30:00')
select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where ((`col_ts` >= '2018-10-28 00:30:00') and (`col_ts` <= '2018-10-28 01:30:00'))
select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where (`col_ts` > '2018-03-25 01:00:00')
select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` where (`col_ts` > '1970-01-01 00:00:01')
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > '2017-12-31 23:00:00')
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` < '2018-10-28 01:30:00')
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where ('2018-10-28 01:30:00' > t0.`col_ts`)
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` between '2018-10-28 00:30:00' and '2018-10-28 01:30:00')
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where ((t0.`col_ts` >= '2018-10-28 00:30:00') and (t0.`col_ts` <= '2018-10-28 01:30:00'))
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > '2018-03-25 01:00:00')
select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > '1970-01-01 00:00:01')
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'
SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a;
col_a col_dt col_ts unix_timestamp(col_ts)
......@@ -343,6 +356,54 @@ col_a col_dt col_ts unix_timestamp(col_ts)
5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200
6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647
Test the TIMESTAMP function
connection master_1;
INSERT INTO tbl_f VALUES ('2018-06-24', '01:23:45'),
('2018-06-24', '01:23:45'),
('2018-08-01', '12:34:56');
connection child2_1;
TRUNCATE TABLE mysql.general_log;
connection master_1;
SELECT * FROM tbl_f;
col_d col_t
2018-06-24 01:23:45
2018-06-24 01:23:45
2018-08-01 12:34:56
SELECT TIMESTAMP(col_d, col_t) FROM tbl_f;
TIMESTAMP(col_d, col_t)
2018-06-24 01:23:45
2018-06-24 01:23:45
2018-08-01 12:34:56
SELECT TIMESTAMP('2018-06-25', col_t) FROM tbl_f;
TIMESTAMP('2018-06-25', col_t)
2018-06-25 01:23:45
2018-06-25 01:23:45
2018-06-25 12:34:56
SELECT TIMESTAMP(col_d, '10:43:21') FROM tbl_f;
TIMESTAMP(col_d, '10:43:21')
2018-06-24 10:43:21
2018-06-24 10:43:21
2018-08-01 10:43:21
SELECT TIMESTAMP('2018-06-25', '10:43:21') FROM tbl_f;
TIMESTAMP('2018-06-25', '10:43:21')
2018-06-25 10:43:21
2018-06-25 10:43:21
2018-06-25 10:43:21
connection child2_1;
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
argument
select t0.`col_d` `col_d`,t0.`col_t` `col_t` from `ts_test_remote`.`tbl_f` t0
select (timestamp(t0.`col_d` , t0.`col_t`)) `TIMESTAMP(col_d, col_t)` from `ts_test_remote`.`tbl_f` t0
select (timestamp('2018-06-25' , t0.`col_t`)) `TIMESTAMP('2018-06-25', col_t)` from `ts_test_remote`.`tbl_f` t0
select (timestamp(t0.`col_d` , '10:43:21')) `TIMESTAMP(col_d, '10:43:21')` from `ts_test_remote`.`tbl_f` t0
select (timestamp('2018-06-25' , '10:43:21')) `TIMESTAMP('2018-06-25', '10:43:21')` from `ts_test_remote`.`tbl_f` t0
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'
SELECT col_d, col_t FROM tbl_f;
col_d col_t
2018-06-24 01:23:45
2018-06-24 01:23:45
2018-08-01 12:34:56
Restore Time Zone settings
connection master_1;
SET GLOBAL time_zone=DEFAULT;
......
......@@ -66,13 +66,17 @@ if ($USE_CHILD_GROUP2)
if ($OUTPUT_CHILD_GROUP2)
{
--disable_query_log
echo CHILD2_1_DROP_TABLES;
echo CHILD2_1_CREATE_TABLES;
echo CHILD2_1_DROP_TABLE;
echo CHILD2_1_DROP_TABLE_F;
echo CHILD2_1_CREATE_TABLE;
echo CHILD2_1_CREATE_TABLE_F;
}
--disable_warnings
eval $CHILD2_1_DROP_TABLES;
eval $CHILD2_1_DROP_TABLE;
eval $CHILD2_1_DROP_TABLE_F;
--enable_warnings
eval $CHILD2_1_CREATE_TABLES;
eval $CHILD2_1_CREATE_TABLE;
eval $CHILD2_1_CREATE_TABLE_F;
if ($OUTPUT_CHILD_GROUP2)
{
--enable_query_log
......@@ -98,7 +102,7 @@ echo CREATE TABLE tbl_a (
col_ts TIMESTAMP NOT NULL
DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY(col_a),
UNIQUE INDEX i_ts (col_ts)
) MASTER_1_ENGINE MASTER_1_AUTO_INCREMENT_2_1 MASTER_1_COMMENT_2_1;
eval CREATE TABLE tbl_a (
col_a INT UNSIGNED NOT NULL AUTO_INCREMENT,
......@@ -108,8 +112,17 @@ eval CREATE TABLE tbl_a (
PRIMARY KEY(col_a),
UNIQUE INDEX i_ts (col_ts)
) $MASTER_1_ENGINE $MASTER_1_AUTO_INCREMENT_2_1 $MASTER_1_COMMENT_2_1;
echo CREATE TABLE tbl_f (
col_d DATE,
col_t TIME
) $MASTER_1_ENGINE $MASTER_1_COMMENT_2_1_F;
eval CREATE TABLE tbl_f (
col_d DATE,
col_t TIME
) $MASTER_1_ENGINE $MASTER_1_COMMENT_2_1_F;
--enable_query_log
SHOW CREATE TABLE tbl_a;
SHOW CREATE TABLE tbl_f;
--echo
--echo Set a different time zone that has DST
......@@ -171,7 +184,7 @@ if ($USE_CHILD_GROUP2)
{
eval $CHILD2_1_SELECT_ARGUMENT1;
}
eval $CHILD2_1_SELECT_TABLES;
eval $CHILD2_1_SELECT_TABLE;
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
......@@ -214,7 +227,7 @@ if ($USE_CHILD_GROUP2)
{
eval $CHILD2_1_SELECT_ARGUMENT1;
}
eval $CHILD2_1_SELECT_TABLES;
eval $CHILD2_1_SELECT_TABLE;
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
......@@ -256,7 +269,7 @@ if ($USE_CHILD_GROUP2)
{
eval $CHILD2_1_SELECT_ARGUMENT1;
}
eval $CHILD2_1_SELECT_TABLES;
eval $CHILD2_1_SELECT_TABLE;
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
......@@ -299,7 +312,7 @@ if ($USE_CHILD_GROUP2)
{
eval $CHILD2_1_SELECT_ARGUMENT1;
}
eval $CHILD2_1_SELECT_TABLES;
eval $CHILD2_1_SELECT_TABLE;
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
......@@ -347,7 +360,7 @@ if ($USE_CHILD_GROUP2)
{
eval $CHILD2_1_SELECT_ARGUMENT1;
}
eval $CHILD2_1_SELECT_TABLES;
eval $CHILD2_1_SELECT_TABLE;
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
......@@ -425,7 +438,57 @@ if ($USE_CHILD_GROUP2)
{
eval $CHILD2_1_SELECT_ARGUMENT1;
}
eval $CHILD2_1_SELECT_TABLES;
eval $CHILD2_1_SELECT_TABLE;
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--echo
--echo Test the TIMESTAMP function
--connection master_1
INSERT INTO tbl_f VALUES ('2018-06-24', '01:23:45'),
('2018-06-24', '01:23:45'),
('2018-08-01', '12:34:56');
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
if ($USE_GENERAL_LOG)
{
TRUNCATE TABLE mysql.general_log;
}
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--connection master_1
SELECT * FROM tbl_f;
SELECT TIMESTAMP(col_d, col_t) FROM tbl_f;
SELECT TIMESTAMP('2018-06-25', col_t) FROM tbl_f;
SELECT TIMESTAMP(col_d, '10:43:21') FROM tbl_f;
SELECT TIMESTAMP('2018-06-25', '10:43:21') FROM tbl_f;
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
if ($USE_GENERAL_LOG)
{
eval $CHILD2_1_SELECT_ARGUMENT1;
}
eval $CHILD2_1_SELECT_TABLE_F;
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
......
......@@ -7,8 +7,11 @@
--enable_warnings
--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1
--let $MASTER_1_COMMENT_2_1_F_BACKUP= $MASTER_1_COMMENT_2_1_F
let $MASTER_1_COMMENT_2_1=
COMMENT='database "ts_test_remote", table "tbl_a", srv "s_2_1"';
let $MASTER_1_COMMENT_2_1_F=
COMMENT='database "ts_test_remote", table "tbl_f", srv "s_2_1"';
let $MASTER_1_AUTO_INCREMENT_2_1=
AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4;
let $MASTER_1_AUTO_INCREMENT1=
......@@ -17,11 +20,15 @@ let $MASTER_1_AUTO_INCREMENT2=
AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4;
let $CHILD2_1_AUTO_INCREMENT=
AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4;
--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES
let $CHILD2_1_DROP_TABLES=
--let $CHILD2_1_DROP_TABLE_BACKUP= $CHILD2_1_DROP_TABLE
--let $CHILD2_1_DROP_TABLE_F_BACKUP= $CHILD2_1_DROP_TABLE_F
let $CHILD2_1_DROP_TABLE=
DROP TABLE IF EXISTS tbl_a;
--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES
let $CHILD2_1_CREATE_TABLES=
let $CHILD2_1_DROP_TABLE_F=
DROP TABLE IF EXISTS tbl_f;
--let $CHILD2_1_CREATE_TABLE_BACKUP= $CHILD2_1_CREATE_TABLE
--let $CHILD2_1_CREATE_TABLE_F_BACKUP= $CHILD2_1_CREATE_TABLE_F
let $CHILD2_1_CREATE_TABLE=
CREATE TABLE tbl_a (
col_a INT UNSIGNED NOT NULL AUTO_INCREMENT,
col_dt DATETIME,
......@@ -30,15 +37,25 @@ let $CHILD2_1_CREATE_TABLES=
PRIMARY KEY(col_a),
UNIQUE INDEX i_ts (col_ts)
) $CHILD2_1_ENGINE $CHILD2_1_AUTO_INCREMENT;
--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES
let $CHILD2_1_SELECT_TABLES=
let $CHILD2_1_CREATE_TABLE_F=
CREATE TABLE tbl_f (
col_d DATE,
col_t TIME
) $CHILD2_1_ENGINE;
--let $CHILD2_1_SELECT_TABLE_BACKUP= $CHILD2_1_SELECT_TABLE
--let $CHILD2_1_SELECT_TABLE_F_BACKUP= $CHILD2_1_SELECT_TABLE_F
let $CHILD2_1_SELECT_TABLE=
SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a;
let $CHILD2_1_SELECT_TABLE_F=
SELECT col_d, col_t FROM tbl_f;
let $CHILD2_1_SELECT_ARGUMENT1=
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
let $CHILD2_1_DROP_INDEX=
DROP INDEX i_ts ON tbl_a;
let $CHILD2_1_SHOW_CREATE_TABLE=
SHOW CREATE TABLE tbl_a;
let $CHILD2_1_SHOW_CREATE_TABLE_F=
SHOW CREATE TABLE tbl_f;
--let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2
--let $OUTPUT_CHILD_GROUP2= 1
--let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG
......
......@@ -12877,7 +12877,8 @@ int spider_mysql_handler::append_list_item_select(
uint dbton_id = spider_dbton_mysql.dbton_id, length;
List_iterator_fast<Item> it(*select);
Item *item;
Field **field_ptr;
Field *field;
const char *item_name;
DBUG_ENTER("spider_mysql_handler::append_list_item_select");
DBUG_PRINT("info",("spider this=%p", this));
while ((item = it++))
......@@ -12888,8 +12889,17 @@ int spider_mysql_handler::append_list_item_select(
{
DBUG_RETURN(error_num);
}
field_ptr = fields->get_next_field_ptr();
length = (*field_ptr)->field_name.length;
field = *(fields->get_next_field_ptr());
if (field)
{
item_name = field->field_name.str;
length = field->field_name.length;
}
else
{
item_name = item->name.str;
length = item->name.length;
}
if (str->reserve(
SPIDER_SQL_COMMA_LEN + /* SPIDER_SQL_NAME_QUOTE_LEN */ 2 +
SPIDER_SQL_SPACE_LEN + length
......@@ -12897,7 +12907,7 @@ int spider_mysql_handler::append_list_item_select(
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN);
if ((error_num = spider_db_mysql_utility.append_name(str,
(*field_ptr)->field_name.str, length)))
item_name, length)))
{
DBUG_RETURN(error_num);
}
......
......@@ -4679,15 +4679,20 @@ SPIDER_SHARE *spider_get_share(
}
if (!share->link_status_init)
{
if (
(
table_share->tmp_table == NO_TMP_TABLE &&
sql_command != SQLCOM_DROP_TABLE &&
sql_command != SQLCOM_SHOW_CREATE
) ||
/* for alter change link status */
sql_command == SQLCOM_ALTER_TABLE
) {
/*
The link statuses need to be refreshed from the spider_tables table
if the operation:
- Is not a DROP TABLE on a permanent table; or
- Is an ALTER TABLE.
Note that SHOW CREATE TABLE is not excluded, because the commands
that follow it require up-to-date link statuses.
*/
if ((table_share->tmp_table == NO_TMP_TABLE &&
sql_command != SQLCOM_DROP_TABLE) ||
/* for alter change link status */
sql_command == SQLCOM_ALTER_TABLE)
{
SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME));
init_mem_root = TRUE;
if (
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment