Skip to content

Commit

Permalink
MDEV-32753 Make spider init queries compatible with oracle sql mode
Browse files Browse the repository at this point in the history
Remove ORACLE from the (session) sql_mode in connections made with sql
service to run init queries

The connection is new and the global variable value takes effect
rather than the session value from the caller of spider_db_init.
  • Loading branch information
mariadb-YuchenPei committed Dec 7, 2023
1 parent 69389c0 commit ba94778
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 1 deletion.
10 changes: 10 additions & 0 deletions storage/spider/mysql-test/spider/bugfix/r/mdev_32753.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# MDEV-32753 Spider engine does not load in ORACLE mode
#
select * from mysql.plugin;
name dl
create table t (c int) Engine=SPIDER;
drop table t;
#
# end of test mdev_32753
#
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# MDEV-32753 Spider engine does not load in ORACLE mode
#
install soname 'ha_spider';
select * from mysql.plugin;
name dl
SPIDER ha_spider.so
SPIDER_ALLOC_MEM ha_spider.so
create table t (c int) Engine=SPIDER;
drop table t;
#
# end of test mdev_32753_after_start
#
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# MDEV-32753 Spider engine does not load in ORACLE mode
#
set @old_sql_mode=@@sql_mode;
SET @@sql_mode = CONCAT(@@sql_mode, ',ORACLE');
install soname 'ha_spider';
select * from mysql.plugin;
name dl
SPIDER ha_spider.so
SPIDER_ALLOC_MEM ha_spider.so
create table t (c int) Engine=SPIDER;
drop table t;
set sql_mode=@old_sql_mode;
#
# end of test mdev_32753_after_start
#
2 changes: 2 additions & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_32753.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sql-mode=oracle
--plugin-load-add=ha_spider
12 changes: 12 additions & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_32753.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--echo #
--echo # MDEV-32753 Spider engine does not load in ORACLE mode
--echo #

# This test tests spider init during server startup under global
# ORACLE mode
select * from mysql.plugin;
create table t (c int) Engine=SPIDER;
drop table t;
--echo #
--echo # end of test mdev_32753
--echo #
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sql-mode=oracle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--echo #
--echo # MDEV-32753 Spider engine does not load in ORACLE mode
--echo #

# This test tests spider init after startup under global ORACLE mode
install soname 'ha_spider';
select * from mysql.plugin;
create table t (c int) Engine=SPIDER;
drop table t;

--disable_query_log
--disable_result_log
--source ../../include/clean_up_spider.inc
--enable_result_log
--enable_query_log

--echo #
--echo # end of test mdev_32753_after_start
--echo #
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--echo #
--echo # MDEV-32753 Spider engine does not load in ORACLE mode
--echo #

# This test tests spider init after startup under session ORACLE mode
set @old_sql_mode=@@sql_mode;
SET @@sql_mode = CONCAT(@@sql_mode, ',ORACLE');
install soname 'ha_spider';
select * from mysql.plugin;
create table t (c int) Engine=SPIDER;
drop table t;
set sql_mode=@old_sql_mode;

--disable_query_log
--disable_result_log
--source ../../include/clean_up_spider.inc
--enable_result_log
--enable_query_log

--echo #
--echo # end of test mdev_32753_after_start
--echo #
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ DROP FUNCTION spider_copy_tables;
DROP FUNCTION spider_ping_table;
DROP FUNCTION spider_bg_direct_sql;
DROP FUNCTION spider_direct_sql;
UNINSTALL SONAME IF EXISTS "ha_spider";
UNINSTALL SONAME IF EXISTS 'ha_spider';
DROP TABLE IF EXISTS mysql.spider_xa;
DROP TABLE IF EXISTS mysql.spider_xa_member;
DROP TABLE IF EXISTS mysql.spider_xa_failed_log;
Expand Down
3 changes: 3 additions & 0 deletions storage/spider/spd_init_query.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
*/

static LEX_STRING spider_init_queries[] = {
{C_STRING_WITH_LEN(
"SET @@SQL_MODE = REPLACE(@@SQL_MODE, 'ORACLE', '');"
)},
{C_STRING_WITH_LEN(
"create table if not exists mysql.spider_xa("
" format_id int not null default 0,"
Expand Down

0 comments on commit ba94778

Please sign in to comment.