From dabd51c3912484b97f92f091b6ab7b20409d9f0c Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 2 Apr 2025 14:47:53 +1100 Subject: [PATCH] MDEV-36335 MDEV-35452 Disable view protocol when calling spider_copy_tables in tests Spider needs to lock the spider table when executing the udf, but the server layer would have already locked tables in view protocol because it transforms the query: select spider_copy_table('t', 0, 1) to two queries create or replace view mysqltest_tmp_v as select spider_copy_table('t', 0, 1); select * from mysqltest_tmp_v; So spider justifiably errors out in this case by checking on thd->derived_tables and thd->locks in spider_copy_tables_body() --- storage/spider/mysql-test/spider/bg/t/ha.test | 2 ++ storage/spider/mysql-test/spider/bg/t/ha_part.test | 2 ++ storage/spider/mysql-test/spider/bugfix/t/mdev_30649.test | 2 ++ storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test | 4 ++++ storage/spider/mysql-test/spider/handler/t/ha.test | 2 ++ storage/spider/mysql-test/spider/handler/t/ha_part.test | 2 ++ storage/spider/mysql-test/spider/t/ha.test | 2 ++ storage/spider/mysql-test/spider/t/ha_part.test | 2 ++ 8 files changed, 18 insertions(+) diff --git a/storage/spider/mysql-test/spider/bg/t/ha.test b/storage/spider/mysql-test/spider/bg/t/ha.test index 00dcf776836..aca4d47b646 100644 --- a/storage/spider/mysql-test/spider/bg/t/ha.test +++ b/storage/spider/mysql-test/spider/bg/t/ha.test @@ -395,7 +395,9 @@ if ($USE_CHILD_GROUP3) --connection master_1 eval $MASTER_1_SET_RECOVERY_STATUS_2_1; eval $MASTER_1_CHECK_LINK_STATUS; +--disable_view_protocol eval $MASTER_1_COPY_TABLES_2_1; +--enable_view_protocol if ($USE_CHILD_GROUP3) { if (!$OUTPUT_CHILD_GROUP3) diff --git a/storage/spider/mysql-test/spider/bg/t/ha_part.test b/storage/spider/mysql-test/spider/bg/t/ha_part.test index 72ddcfd1f10..b7d27b0d69d 100644 --- a/storage/spider/mysql-test/spider/bg/t/ha_part.test +++ b/storage/spider/mysql-test/spider/bg/t/ha_part.test @@ -460,7 +460,9 @@ if ($HAVE_PARTITION) --connection master_1 eval $MASTER_1_SET_RECOVERY_STATUS_P_2_1; eval $MASTER_1_CHECK_LINK_STATUS; + --disable_view_protocol eval $MASTER_1_COPY_TABLES_P_2_1; + --enable_view_protocol if ($USE_CHILD_GROUP3) { if (!$OUTPUT_CHILD_GROUP3) diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_30649.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_30649.test index 02df6032887..8a7141e5248 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_30649.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_30649.test @@ -25,7 +25,9 @@ INSERT INTO dst VALUES (555, '1999-12-12'); # possibly a bug, e.g. an unnecessary requirement. evalp CREATE TABLE t (c INT, d DATE, PRIMARY KEY(c)) ENGINE=SPIDER COMMENT='table "src dst", srv "s_2_1 s_1"'; +--disable_view_protocol SELECT spider_copy_tables('t', '0', '1'); +--enable_view_protocol SELECT * FROM dst; diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test index ebd08edce24..294675d2f4c 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test @@ -7,8 +7,10 @@ CREATE FUNCTION spider_bg_direct_sql RETURNS INT SONAME 'ha_spider.so'; SELECT spider_bg_direct_sql ('SELECT * FROM s','a','srv "b"'); CREATE FUNCTION spider_copy_tables RETURNS INT SONAME 'ha_spider.so'; +--disable_view_protocol --error ER_CANT_INITIALIZE_UDF SELECT spider_copy_tables ('t', '0', '0'); +--enable_view_protocol # spider_flush_table_mon_cache does not require spider init to function CREATE FUNCTION spider_flush_table_mon_cache RETURNS INT SONAME 'ha_spider.so'; @@ -21,8 +23,10 @@ install soname 'ha_spider'; SELECT spider_direct_sql ('SELECT * FROM s','a','srv "b"'); call mtr.add_suppression(".*\\[Error\\] (mysqld|mariadbd): Can't find record in 'spider_tables'"); +--disable_view_protocol --error ER_KEY_NOT_FOUND SELECT spider_copy_tables ('t', '0', '0'); +--enable_view_protocol SELECT spider_flush_table_mon_cache (); diff --git a/storage/spider/mysql-test/spider/handler/t/ha.test b/storage/spider/mysql-test/spider/handler/t/ha.test index 00dcf776836..aca4d47b646 100644 --- a/storage/spider/mysql-test/spider/handler/t/ha.test +++ b/storage/spider/mysql-test/spider/handler/t/ha.test @@ -395,7 +395,9 @@ if ($USE_CHILD_GROUP3) --connection master_1 eval $MASTER_1_SET_RECOVERY_STATUS_2_1; eval $MASTER_1_CHECK_LINK_STATUS; +--disable_view_protocol eval $MASTER_1_COPY_TABLES_2_1; +--enable_view_protocol if ($USE_CHILD_GROUP3) { if (!$OUTPUT_CHILD_GROUP3) diff --git a/storage/spider/mysql-test/spider/handler/t/ha_part.test b/storage/spider/mysql-test/spider/handler/t/ha_part.test index 72ddcfd1f10..b7d27b0d69d 100644 --- a/storage/spider/mysql-test/spider/handler/t/ha_part.test +++ b/storage/spider/mysql-test/spider/handler/t/ha_part.test @@ -460,7 +460,9 @@ if ($HAVE_PARTITION) --connection master_1 eval $MASTER_1_SET_RECOVERY_STATUS_P_2_1; eval $MASTER_1_CHECK_LINK_STATUS; + --disable_view_protocol eval $MASTER_1_COPY_TABLES_P_2_1; + --enable_view_protocol if ($USE_CHILD_GROUP3) { if (!$OUTPUT_CHILD_GROUP3) diff --git a/storage/spider/mysql-test/spider/t/ha.test b/storage/spider/mysql-test/spider/t/ha.test index 00dcf776836..aca4d47b646 100644 --- a/storage/spider/mysql-test/spider/t/ha.test +++ b/storage/spider/mysql-test/spider/t/ha.test @@ -395,7 +395,9 @@ if ($USE_CHILD_GROUP3) --connection master_1 eval $MASTER_1_SET_RECOVERY_STATUS_2_1; eval $MASTER_1_CHECK_LINK_STATUS; +--disable_view_protocol eval $MASTER_1_COPY_TABLES_2_1; +--enable_view_protocol if ($USE_CHILD_GROUP3) { if (!$OUTPUT_CHILD_GROUP3) diff --git a/storage/spider/mysql-test/spider/t/ha_part.test b/storage/spider/mysql-test/spider/t/ha_part.test index 7e9d6f7715c..123b100a474 100644 --- a/storage/spider/mysql-test/spider/t/ha_part.test +++ b/storage/spider/mysql-test/spider/t/ha_part.test @@ -460,7 +460,9 @@ if ($HAVE_PARTITION) --connection master_1 eval $MASTER_1_SET_RECOVERY_STATUS_P_2_1; eval $MASTER_1_CHECK_LINK_STATUS; + --disable_view_protocol eval $MASTER_1_COPY_TABLES_P_2_1; + --enable_view_protocol if ($USE_CHILD_GROUP3) { if (!$OUTPUT_CHILD_GROUP3)