diff options
-rw-r--r-- | sql/ha_partition.cc | 50 | ||||
-rw-r--r-- | sql/ha_partition.h | 8 | ||||
-rw-r--r-- | storage/spider/mysql-test/spider/include/init_child2_1.inc | 14 | ||||
-rw-r--r-- | storage/spider/mysql-test/spider/include/init_master_1.inc | 4 | ||||
-rw-r--r-- | storage/spider/mysql-test/spider/r/spider_fixes_part.result | 49 | ||||
-rw-r--r-- | storage/spider/mysql-test/spider/t/spider_fixes_part.test | 109 |
6 files changed, 234 insertions, 0 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index d4ecc0d3970..43f936cf200 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -9130,6 +9130,56 @@ int ha_partition::check_for_upgrade(HA_CHECK_OPT *check_opt) } +/** + Push an engine condition to the condition stack of the storage engine + for each partition. + + @param cond Pointer to the engine condition to be pushed. + + @return NULL Underlying engine will not return rows that + do not match the passed condition. + <> NULL 'Remainder' condition that the caller must use + to filter out records. +*/ + +const COND *ha_partition::cond_push(const COND *cond) +{ + handler **file= m_file; + COND *res_cond= NULL; + DBUG_ENTER("ha_partition::cond_push"); + + do + { + if ((*file)->pushed_cond != cond) + { + if ((*file)->cond_push(cond)) + res_cond= (COND *) cond; + else + (*file)->pushed_cond= cond; + } + } while (*(++file)); + DBUG_RETURN(res_cond); +} + + +/** + Pop the top condition from the condition stack of the storage engine + for each partition. +*/ + +void ha_partition::cond_pop() +{ + handler **file= m_file; + DBUG_ENTER("ha_partition::cond_pop"); + + do + { + (*file)->cond_pop(); + } while (*(++file)); + DBUG_VOID_RETURN; +} + + struct st_mysql_storage_engine partition_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION }; diff --git a/sql/ha_partition.h b/sql/ha_partition.h index a301cc3871c..286c6961531 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -1200,6 +1200,14 @@ public: virtual bool is_crashed() const; virtual int check_for_upgrade(HA_CHECK_OPT *check_opt); + /* + ----------------------------------------------------------------------- + MODULE condition pushdown + ----------------------------------------------------------------------- + */ + virtual const COND *cond_push(const COND *cond); + virtual void cond_pop(); + private: int handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt, uint flags); int handle_opt_part(THD *thd, HA_CHECK_OPT *check_opt, uint part_id, diff --git a/storage/spider/mysql-test/spider/include/init_child2_1.inc b/storage/spider/mysql-test/spider/include/init_child2_1.inc index 10793649f94..782f538eb43 100644 --- a/storage/spider/mysql-test/spider/include/init_child2_1.inc +++ b/storage/spider/mysql-test/spider/include/init_child2_1.inc @@ -69,6 +69,20 @@ let $CHILD2_1_CREATE_TABLES6= ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; let $CHILD2_1_SELECT_TABLES6= SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r_3 ORDER BY a; +let $CHILD2_1_DROP_TABLES7= + DROP TABLE IF EXISTS ta_ob; +let $CHILD2_1_CREATE_TABLES7= + CREATE TABLE ta_ob ( + a VARCHAR(50) NOT NULL, + b VARCHAR(50) NULL DEFAULT NULL, + c VARCHAR(100) NULL DEFAULT NULL, + d DATETIME(0) NULL DEFAULT NULL, + e INT(11) NOT NULL, + f INT(10) NULL DEFAULT NULL, + PRIMARY KEY (a, e) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +let $CHILD2_1_SELECT_TABLES7= + SELECT * FROM ta_ob WHERE c LIKE "%510411106%" AND e = 510411 AND f != 1 ORDER BY d,c LIMIT 6 OFFSET 0; let $CHILD2_1_DROP_FT_TABLES= DROP TABLE IF EXISTS ft_r; let $CHILD2_1_CREATE_FT_TABLES= diff --git a/storage/spider/mysql-test/spider/include/init_master_1.inc b/storage/spider/mysql-test/spider/include/init_master_1.inc index 93947a8d454..2c45d0bd65d 100644 --- a/storage/spider/mysql-test/spider/include/init_master_1.inc +++ b/storage/spider/mysql-test/spider/include/init_master_1.inc @@ -94,6 +94,10 @@ if (!$VERSION_COMPILE_OS_WIN) CONNECTION='host "localhost", socket "$CHILD2_1_MYSOCK", user "root", password ""'; } +let $MASTER_1_COMMENT6_P_1_1= + COMMENT='database "auto_test_remote", table "ta_ob"' + PARTITION BY LIST COLUMNS (e) PARTITIONS 1 + (PARTITION pt1 values in (510411) COMMENT = 'srv "s_2_1"'); if ($VERSION_COMPILE_OS_WIN) { let $MASTER_1_COMMENT_FT_2_1= diff --git a/storage/spider/mysql-test/spider/r/spider_fixes_part.result b/storage/spider/mysql-test/spider/r/spider_fixes_part.result index faf0b6efbea..d2367af9bbd 100644 --- a/storage/spider/mysql-test/spider/r/spider_fixes_part.result +++ b/storage/spider/mysql-test/spider/r/spider_fixes_part.result @@ -214,6 +214,55 @@ id 10000 connection master_1; +Test ORDER BY with LIMIT and OFFSET +connection master_1; +CREATE TABLE ta_ob ( +a VARCHAR(50) NOT NULL, +b VARCHAR(50) NULL DEFAULT NULL, +c VARCHAR(100) NULL DEFAULT NULL, +d DATETIME(0) NULL DEFAULT NULL, +e INT(11) NOT NULL, +f INT(10) NULL DEFAULT NULL, +PRIMARY KEY (a, e) +) ENGINE=Spider COMMENT='database "auto_test_remote", table "ta_ob"' + PARTITION BY LIST COLUMNS (e) PARTITIONS 1 +(PARTITION pt1 values in (510411) COMMENT = 'srv "s_2_1"') +INSERT INTO ta_ob VALUES ('0B95CD65DF994BC9A09A6AABE53A2733', +'6CFED89FF6A84C7AA55C3C432663D094', +'51041110620304', '2018-08-02 13:41:13', +510411, 1); +INSERT INTO ta_ob VALUES ('15E8D55EF099443BAEE639E60A4650BD', +'879DC2A0B6AC46D9A62E8EA47E2970F2', +'51041110620301', NULL, +510411, 0); +INSERT INTO ta_ob VALUES ('51ECF2C0CD3C48D99C91792E99D3C1A0', +'017B8A460DBC444682B791305EF75356', +'51041110620308', '2018-08-02 13:48:29', +510411, 0); +INSERT INTO ta_ob VALUES ('093B37A93A534DF883787AF5F6799674', +'996C7F14989D480589A553717D735E3E', +'51041110620302', '2018-08-02 13:48:30', +510411, 0); +INSERT INTO ta_ob VALUES ('53F5266FB069499AB6234755CACA2583', +'017B8A460DBC444682B791305EF75356', +'51041110620308', '2018-08-02 13:48:28', +510411, 0); +INSERT INTO ta_ob VALUES ('56E59BC4BDC143868D4A219C2D07A24B', +'821E71E6ABB4404EBAA349BB681089F8', +'51041110620310', '2018-08-02 13:48:27', +510411, 0); +INSERT INTO ta_ob VALUES ('56B68DA68D6D4A04A08B453D09AD7B70', +'821E71E6ABB4404EBAA349BB681089F8', +'51041110620310', '2018-08-02 13:48:28', +510411, 0); +SELECT * FROM ta_ob WHERE c LIKE "%510411106%" AND e = 510411 AND f != 1 ORDER BY d,c LIMIT 5 OFFSET 1; +a b c d e f +56E59BC4BDC143868D4A219C2D07A24B 821E71E6ABB4404EBAA349BB681089F8 51041110620310 2018-08-02 13:48:27 510411 0 +53F5266FB069499AB6234755CACA2583 017B8A460DBC444682B791305EF75356 51041110620308 2018-08-02 13:48:28 510411 0 +56B68DA68D6D4A04A08B453D09AD7B70 821E71E6ABB4404EBAA349BB681089F8 51041110620310 2018-08-02 13:48:28 510411 0 +51ECF2C0CD3C48D99C91792E99D3C1A0 017B8A460DBC444682B791305EF75356 51041110620308 2018-08-02 13:48:29 510411 0 +093B37A93A534DF883787AF5F6799674 996C7F14989D480589A553717D735E3E 51041110620302 2018-08-02 13:48:30 510411 0 + deinit connection master_1; DROP DATABASE IF EXISTS auto_test_local; diff --git a/storage/spider/mysql-test/spider/t/spider_fixes_part.test b/storage/spider/mysql-test/spider/t/spider_fixes_part.test index ef5a8026c02..868e684f959 100644 --- a/storage/spider/mysql-test/spider/t/spider_fixes_part.test +++ b/storage/spider/mysql-test/spider/t/spider_fixes_part.test @@ -616,6 +616,115 @@ if ($HAVE_PARTITION) } } +--echo +--echo Test ORDER BY with LIMIT and OFFSET +if ($HAVE_PARTITION) +{ + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($OUTPUT_CHILD_GROUP2) + { + --disable_query_log + echo CHILD2_1_DROP_TABLES7; + echo CHILD2_1_CREATE_TABLES7; + } + --disable_warnings + eval $CHILD2_1_DROP_TABLES7; + --enable_warnings + eval $CHILD2_1_CREATE_TABLES7; + if ($OUTPUT_CHILD_GROUP2) + { + --enable_query_log + } + if ($USE_GENERAL_LOG) + { + TRUNCATE TABLE mysql.general_log; + } + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } + --connection master_1 + --disable_query_log + --disable_warnings + DROP TABLE IF EXISTS ta_ob; + --enable_warnings + echo CREATE TABLE ta_ob ( + a VARCHAR(50) NOT NULL, + b VARCHAR(50) NULL DEFAULT NULL, + c VARCHAR(100) NULL DEFAULT NULL, + d DATETIME(0) NULL DEFAULT NULL, + e INT(11) NOT NULL, + f INT(10) NULL DEFAULT NULL, + PRIMARY KEY (a, e) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT6_P_1_1; + eval CREATE TABLE ta_ob ( + a VARCHAR(50) NOT NULL, + b VARCHAR(50) NULL DEFAULT NULL, + c VARCHAR(100) NULL DEFAULT NULL, + d DATETIME(0) NULL DEFAULT NULL, + e INT(11) NOT NULL, + f INT(10) NULL DEFAULT NULL, + PRIMARY KEY (a, e) + ) $MASTER_1_ENGINE $MASTER_1_COMMENT6_P_1_1; + --enable_query_log + INSERT INTO ta_ob VALUES ('0B95CD65DF994BC9A09A6AABE53A2733', + '6CFED89FF6A84C7AA55C3C432663D094', + '51041110620304', '2018-08-02 13:41:13', + 510411, 1); + INSERT INTO ta_ob VALUES ('15E8D55EF099443BAEE639E60A4650BD', + '879DC2A0B6AC46D9A62E8EA47E2970F2', + '51041110620301', NULL, + 510411, 0); + INSERT INTO ta_ob VALUES ('51ECF2C0CD3C48D99C91792E99D3C1A0', + '017B8A460DBC444682B791305EF75356', + '51041110620308', '2018-08-02 13:48:29', + 510411, 0); + INSERT INTO ta_ob VALUES ('093B37A93A534DF883787AF5F6799674', + '996C7F14989D480589A553717D735E3E', + '51041110620302', '2018-08-02 13:48:30', + 510411, 0); + INSERT INTO ta_ob VALUES ('53F5266FB069499AB6234755CACA2583', + '017B8A460DBC444682B791305EF75356', + '51041110620308', '2018-08-02 13:48:28', + 510411, 0); + INSERT INTO ta_ob VALUES ('56E59BC4BDC143868D4A219C2D07A24B', + '821E71E6ABB4404EBAA349BB681089F8', + '51041110620310', '2018-08-02 13:48:27', + 510411, 0); + INSERT INTO ta_ob VALUES ('56B68DA68D6D4A04A08B453D09AD7B70', + '821E71E6ABB4404EBAA349BB681089F8', + '51041110620310', '2018-08-02 13:48:28', + 510411, 0); + SELECT * FROM ta_ob WHERE c LIKE "%510411106%" AND e = 510411 AND f != 1 ORDER BY d,c LIMIT 5 OFFSET 1; + if ($USE_CHILD_GROUP2) + { + if (!$OUTPUT_CHILD_GROUP2) + { + --disable_query_log + --disable_result_log + } + --connection child2_1 + if ($USE_GENERAL_LOG) + { + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + } + eval $CHILD2_1_SELECT_TABLES7; + if (!$OUTPUT_CHILD_GROUP2) + { + --enable_query_log + --enable_result_log + } + } +} --echo --echo deinit |