1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Merge 10.6 into 10.11

This commit is contained in:
Marko Mäkelä
2024-01-17 17:37:15 +02:00
108 changed files with 977 additions and 325 deletions

View File

@@ -242,7 +242,6 @@ SET(HAVE_TERMCAP_H CACHE INTERNAL "")
SET(HAVE_TERMIOS_H CACHE INTERNAL "") SET(HAVE_TERMIOS_H CACHE INTERNAL "")
SET(HAVE_TERMIO_H CACHE INTERNAL "") SET(HAVE_TERMIO_H CACHE INTERNAL "")
SET(HAVE_TERM_H CACHE INTERNAL "") SET(HAVE_TERM_H CACHE INTERNAL "")
SET(HAVE_THR_SETCONCURRENCY CACHE INTERNAL "")
SET(HAVE_THR_YIELD CACHE INTERNAL "") SET(HAVE_THR_YIELD CACHE INTERNAL "")
SET(HAVE_TIME 1 CACHE INTERNAL "") SET(HAVE_TIME 1 CACHE INTERNAL "")
SET(HAVE_TIMES CACHE INTERNAL "") SET(HAVE_TIMES CACHE INTERNAL "")

View File

@@ -232,7 +232,6 @@
#cmakedefine HAVE_STRTOUL 1 #cmakedefine HAVE_STRTOUL 1
#cmakedefine HAVE_STRTOULL 1 #cmakedefine HAVE_STRTOULL 1
#cmakedefine HAVE_TELL 1 #cmakedefine HAVE_TELL 1
#cmakedefine HAVE_THR_SETCONCURRENCY 1
#cmakedefine HAVE_THR_YIELD 1 #cmakedefine HAVE_THR_YIELD 1
#cmakedefine HAVE_TIME 1 #cmakedefine HAVE_TIME 1
#cmakedefine HAVE_TIMES 1 #cmakedefine HAVE_TIMES 1

View File

@@ -418,7 +418,6 @@ CHECK_FUNCTION_EXISTS (strtoul HAVE_STRTOUL)
CHECK_FUNCTION_EXISTS (strtoull HAVE_STRTOULL) CHECK_FUNCTION_EXISTS (strtoull HAVE_STRTOULL)
CHECK_FUNCTION_EXISTS (strcasecmp HAVE_STRCASECMP) CHECK_FUNCTION_EXISTS (strcasecmp HAVE_STRCASECMP)
CHECK_FUNCTION_EXISTS (tell HAVE_TELL) CHECK_FUNCTION_EXISTS (tell HAVE_TELL)
CHECK_FUNCTION_EXISTS (thr_setconcurrency HAVE_THR_SETCONCURRENCY)
CHECK_FUNCTION_EXISTS (thr_yield HAVE_THR_YIELD) CHECK_FUNCTION_EXISTS (thr_yield HAVE_THR_YIELD)
CHECK_FUNCTION_EXISTS (vasprintf HAVE_VASPRINTF) CHECK_FUNCTION_EXISTS (vasprintf HAVE_VASPRINTF)
CHECK_FUNCTION_EXISTS (vsnprintf HAVE_VSNPRINTF) CHECK_FUNCTION_EXISTS (vsnprintf HAVE_VSNPRINTF)

View File

@@ -147,9 +147,6 @@ int pthread_cancel(pthread_t thread);
#ifndef _REENTRANT #ifndef _REENTRANT
#define _REENTRANT #define _REENTRANT
#endif #endif
#ifdef HAVE_THR_SETCONCURRENCY
#include <thread.h> /* Probably solaris */
#endif
#ifdef HAVE_SCHED_H #ifdef HAVE_SCHED_H
#include <sched.h> #include <sched.h>
#endif #endif
@@ -618,9 +615,6 @@ extern int my_rw_trywrlock(my_rw_lock_t *);
#define GETHOSTBYADDR_BUFF_SIZE 2048 #define GETHOSTBYADDR_BUFF_SIZE 2048
#ifndef HAVE_THR_SETCONCURRENCY
#define thr_setconcurrency(A) pthread_dummy(0)
#endif
#if !defined(HAVE_PTHREAD_ATTR_SETSTACKSIZE) && ! defined(pthread_attr_setstacksize) #if !defined(HAVE_PTHREAD_ATTR_SETSTACKSIZE) && ! defined(pthread_attr_setstacksize)
#define pthread_attr_setstacksize(A,B) pthread_dummy(0) #define pthread_attr_setstacksize(A,B) pthread_dummy(0)
#endif #endif

View File

@@ -531,7 +531,13 @@ struct st_mysql_plugin
const char *author; /* plugin author (for I_S.PLUGINS) */ const char *author; /* plugin author (for I_S.PLUGINS) */
const char *descr; /* general descriptive text (for I_S.PLUGINS) */ const char *descr; /* general descriptive text (for I_S.PLUGINS) */
int license; /* the plugin license (PLUGIN_LICENSE_XXX) */ int license; /* the plugin license (PLUGIN_LICENSE_XXX) */
int (*init)(void *); /* the function to invoke when plugin is loaded */ /*
The function to invoke when plugin is loaded. Plugin
initialisation done here should defer any ALTER TABLE queries to
after the ddl recovery is done, in the signal_ddl_recovery_done()
callback called by ha_signal_ddl_recovery_done().
*/
int (*init)(void *);
int (*deinit)(void *);/* the function to invoke when plugin is unloaded */ int (*deinit)(void *);/* the function to invoke when plugin is unloaded */
unsigned int version; /* plugin version (for I_S.PLUGINS) */ unsigned int version; /* plugin version (for I_S.PLUGINS) */
struct st_mysql_show_var *status_vars; struct st_mysql_show_var *status_vars;
@@ -555,7 +561,13 @@ struct st_maria_plugin
const char *author; /* plugin author (for SHOW PLUGINS) */ const char *author; /* plugin author (for SHOW PLUGINS) */
const char *descr; /* general descriptive text (for SHOW PLUGINS ) */ const char *descr; /* general descriptive text (for SHOW PLUGINS ) */
int license; /* the plugin license (PLUGIN_LICENSE_XXX) */ int license; /* the plugin license (PLUGIN_LICENSE_XXX) */
int (*init)(void *); /* the function to invoke when plugin is loaded */ /*
The function to invoke when plugin is loaded. Plugin
initialisation done here should defer any ALTER TABLE queries to
after the ddl recovery is done, in the signal_ddl_recovery_done()
callback called by ha_signal_ddl_recovery_done().
*/
int (*init)(void *);
int (*deinit)(void *);/* the function to invoke when plugin is unloaded */ int (*deinit)(void *);/* the function to invoke when plugin is unloaded */
unsigned int version; /* plugin version (for SHOW PLUGINS) */ unsigned int version; /* plugin version (for SHOW PLUGINS) */
struct st_mysql_show_var *status_vars; struct st_mysql_show_var *status_vars;

View File

@@ -634,8 +634,6 @@ int init_embedded_server(int argc, char **argv, char **groups)
udf_init(); udf_init();
#endif #endif
(void) thr_setconcurrency(concurrency); // 10 by default
if (flush_time && flush_time != ~(ulong) 0L) if (flush_time && flush_time != ~(ulong) 0L)
start_handle_manager(); start_handle_manager();

View File

@@ -892,6 +892,12 @@ sub collect_one_test_case {
} }
my @no_combs = grep { $test_combs{$_} == 1 } keys %test_combs; my @no_combs = grep { $test_combs{$_} == 1 } keys %test_combs;
if (@no_combs) { if (@no_combs) {
if ($::opt_skip_not_found) {
push @{$tinfo->{combinations}}, @no_combs;
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "combination not found";
return $tinfo;
}
mtr_error("Could not run $name with '".( mtr_error("Could not run $name with '".(
join(',', sort @no_combs))."' combination(s)"); join(',', sort @no_combs))."' combination(s)");
} }

View File

@@ -768,14 +768,11 @@ INSERT INTO t1 VALUES (-1.0);
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
#enable after MDEV-32645 is fixed
--disable_view_protocol
SELECT CAST(-1e0 AS UNSIGNED); SELECT CAST(-1e0 AS UNSIGNED);
CREATE TABLE t1 (a BIGINT UNSIGNED); CREATE TABLE t1 (a BIGINT UNSIGNED);
INSERT INTO t1 VALUES (-1e0); INSERT INTO t1 VALUES (-1e0);
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
--enable_view_protocol
SELECT CAST(-1e308 AS UNSIGNED); SELECT CAST(-1e308 AS UNSIGNED);
CREATE TABLE t1 (a BIGINT UNSIGNED); CREATE TABLE t1 (a BIGINT UNSIGNED);

View File

@@ -2632,4 +2632,49 @@ a
1 1
1 1
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-31657: CTE with the same name as base table used twice
# in another CTE
#
create table t (a int);
insert into t values (3), (7), (1);
with
t as (select * from t),
cte as (select t1.a as t1a, t2.a as t2a from t as t1, t as t2 where t1.a=t2.a)
select * from cte;
t1a t2a
3 3
7 7
1 1
create table s (a int);
insert into s values (1), (4), (7);
with
t as (select * from t),
s as (select a-1 as a from s),
cte as (select t.a as ta, s.a as sa from t, s where t.a=s.a
union
select t.a+1, s.a+1 from t, s where t.a=s.a+1)
select * from cte;
ta sa
3 3
2 1
8 7
with
t as (select * from t),
cte as (select t.a as ta, s.a as sa from t, s where t.a=s.a
union
select t.a+1, s.a+1 from t, s where t.a=s.a),
s as (select a+10 as a from s)
select * from cte;
ta sa
1 1
7 7
2 2
8 8
drop table t,s;
with
t as (select * from t),
cte as (select t1.a as t1a, t2.a as t2a from t as t1, t as t2 where t1.a=t2.a)
select * from cte;
ERROR 42S02: Table 'test.t' doesn't exist
# End of 10.4 tests # End of 10.4 tests

View File

@@ -1979,4 +1979,50 @@ SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-31657: CTE with the same name as base table used twice
--echo # in another CTE
--echo #
create table t (a int);
insert into t values (3), (7), (1);
let $q1=
with
t as (select * from t),
cte as (select t1.a as t1a, t2.a as t2a from t as t1, t as t2 where t1.a=t2.a)
select * from cte;
eval $q1;
create table s (a int);
insert into s values (1), (4), (7);
let $q2=
with
t as (select * from t),
s as (select a-1 as a from s),
cte as (select t.a as ta, s.a as sa from t, s where t.a=s.a
union
select t.a+1, s.a+1 from t, s where t.a=s.a+1)
select * from cte;
eval $q2;
let $q3=
with
t as (select * from t),
cte as (select t.a as ta, s.a as sa from t, s where t.a=s.a
union
select t.a+1, s.a+1 from t, s where t.a=s.a),
s as (select a+10 as a from s)
select * from cte;
eval $q3;
drop table t,s;
--ERROR ER_NO_SUCH_TABLE
eval $q1;
--echo # End of 10.4 tests --echo # End of 10.4 tests

View File

@@ -1173,6 +1173,43 @@ d 50
fdbl 123.456.789,12345678000000000000000000000000000000 fdbl 123.456.789,12345678000000000000000000000000000000
fdec 123.456.789,12345678900000000000000000000000000000 fdec 123.456.789,12345678900000000000000000000000000000
# #
# MDEV-32645 CAST(AS UNSIGNED) fails with --view-protocol
#
SELECT
CAST(-1e0 AS UNSIGNED),
CAST(--2e0 AS UNSIGNED),
CAST(---3e0 AS UNSIGNED),
CAST(----4e0 AS UNSIGNED);
CAST(-1e0 AS UNSIGNED) CAST(--2e0 AS UNSIGNED) CAST(---3e0 AS UNSIGNED) CAST(----4e0 AS UNSIGNED)
0 2 0 4
Warnings:
Note 1916 Got overflow when converting '-1' to UNSIGNED BIGINT. Value truncated
Note 1916 Got overflow when converting '-3' to UNSIGNED BIGINT. Value truncated
EXPLAIN EXTENDED SELECT
CAST(-1e0 AS UNSIGNED),
CAST(--2e0 AS UNSIGNED),
CAST(---3e0 AS UNSIGNED),
CAST(----4e0 AS UNSIGNED);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select cast(-1e0 as unsigned) AS `CAST(-1e0 AS UNSIGNED)`,cast(2e0 as unsigned) AS `CAST(--2e0 AS UNSIGNED)`,cast(-3e0 as unsigned) AS `CAST(---3e0 AS UNSIGNED)`,cast(4e0 as unsigned) AS `CAST(----4e0 AS UNSIGNED)`
CREATE VIEW v1 AS SELECT
CAST(-1e0 AS UNSIGNED),
CAST(--2e0 AS UNSIGNED),
CAST(---3e0 AS UNSIGNED),
CAST(----4e0 AS UNSIGNED);
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(-1e0 as unsigned) AS `CAST(-1e0 AS UNSIGNED)`,cast(2e0 as unsigned) AS `CAST(--2e0 AS UNSIGNED)`,cast(-3e0 as unsigned) AS `CAST(---3e0 AS UNSIGNED)`,cast(4e0 as unsigned) AS `CAST(----4e0 AS UNSIGNED)` latin1 latin1_swedish_ci
SELECT * FROM v1;
CAST(-1e0 AS UNSIGNED) CAST(--2e0 AS UNSIGNED) CAST(---3e0 AS UNSIGNED) CAST(----4e0 AS UNSIGNED)
0 2 0 4
Warnings:
Note 1916 Got overflow when converting '-1' to UNSIGNED BIGINT. Value truncated
Note 1916 Got overflow when converting '-3' to UNSIGNED BIGINT. Value truncated
DROP VIEW v1;
#
# End of 10.4 tests # End of 10.4 tests
# #
# #

View File

@@ -716,6 +716,32 @@ $$
DELIMITER ;$$ DELIMITER ;$$
--horizontal_results --horizontal_results
--echo #
--echo # MDEV-32645 CAST(AS UNSIGNED) fails with --view-protocol
--echo #
SELECT
CAST(-1e0 AS UNSIGNED),
CAST(--2e0 AS UNSIGNED),
CAST(---3e0 AS UNSIGNED),
CAST(----4e0 AS UNSIGNED);
EXPLAIN EXTENDED SELECT
CAST(-1e0 AS UNSIGNED),
CAST(--2e0 AS UNSIGNED),
CAST(---3e0 AS UNSIGNED),
CAST(----4e0 AS UNSIGNED);
CREATE VIEW v1 AS SELECT
CAST(-1e0 AS UNSIGNED),
CAST(--2e0 AS UNSIGNED),
CAST(---3e0 AS UNSIGNED),
CAST(----4e0 AS UNSIGNED);
SHOW CREATE VIEW v1;
SELECT * FROM v1;
DROP VIEW v1;
--echo # --echo #
--echo # End of 10.4 tests --echo # End of 10.4 tests
--echo # --echo #

View File

@@ -0,0 +1,36 @@
connect master,127.0.0.1,root,,test,$MASTER_MYPORT,;
connect slave,127.0.0.1,root,,test,$SLAVE_MYPORT,;
connection master;
CREATE DATABASE federated;
connection slave;
CREATE DATABASE federated;
#
# MDEV-32984 Update federated table and column privileges
#
connection slave;
create database db1;
create user my@localhost identified by '1qaz2wsx';
create table db1.t1 (
f1 int auto_increment primary key,
f2 varchar(50),
f3 varchar(50),
unique (f2)
);
grant insert, select (f1, f2, f3), update (f3) on db1.t1 to my@localhost;
connection master;
create table tt1 engine=federated connection='mysql://my:1qaz2wsx@localhost:$SLAVE_MYPORT/db1/t1';
insert into tt1 (f2,f3) values ('test','123');
select * from tt1;
f1 f2 f3
1 test 123
update tt1 set f3='123456' where f2='test';
drop table tt1;
connection slave;
drop database db1;
drop user my@localhost;
connection master;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated;
connection slave;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated;

View File

@@ -0,0 +1,32 @@
source include/federated.inc;
source have_federatedx.inc;
--echo #
--echo # MDEV-32984 Update federated table and column privileges
--echo #
connection slave;
create database db1;
create user my@localhost identified by '1qaz2wsx';
create table db1.t1 (
f1 int auto_increment primary key,
f2 varchar(50),
f3 varchar(50),
unique (f2)
);
grant insert, select (f1, f2, f3), update (f3) on db1.t1 to my@localhost;
connection master;
evalp create table tt1 engine=federated connection='mysql://my:1qaz2wsx@localhost:$SLAVE_MYPORT/db1/t1';
insert into tt1 (f2,f3) values ('test','123');
select * from tt1;
update tt1 set f3='123456' where f2='test';
drop table tt1;
connection slave;
drop database db1;
drop user my@localhost;
source include/federated_cleanup.inc;

View File

@@ -1,4 +1,5 @@
CREATE TABLE t (pk int PRIMARY KEY, c varchar(10)) ENGINE=InnoDB; CREATE TABLE t (pk int PRIMARY KEY, c varchar(10))
STATS_PERSISTENT=0 ENGINE=InnoDB;
INSERT INTO t VALUES (10, "0123456789"); INSERT INTO t VALUES (10, "0123456789");
connection default; connection default;
BEGIN; BEGIN;

View File

@@ -3,7 +3,8 @@
--source include/have_debug.inc --source include/have_debug.inc
--source include/have_debug_sync.inc --source include/have_debug_sync.inc
CREATE TABLE t (pk int PRIMARY KEY, c varchar(10)) ENGINE=InnoDB; CREATE TABLE t (pk int PRIMARY KEY, c varchar(10))
STATS_PERSISTENT=0 ENGINE=InnoDB;
INSERT INTO t VALUES (10, "0123456789"); INSERT INTO t VALUES (10, "0123456789");
--connection default --connection default

View File

@@ -253,6 +253,55 @@ NEXTVAL(s)
1 1
DROP SEQUENCE s; DROP SEQUENCE s;
# #
# MDEV-33169 Alter sequence 2nd ps fails while alter sequence 2nd time (no ps) succeeds
#
create sequence s;
show create sequence s;
Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
alter sequence s maxvalue 123;
show create sequence s;
Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 123 increment by 1 cache 1000 nocycle ENGINE=MyISAM
alter sequence s maxvalue 123;
show create sequence s;
Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 123 increment by 1 cache 1000 nocycle ENGINE=MyISAM
drop sequence s;
create sequence s;
show create sequence s;
Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
prepare stmt from 'alter sequence s maxvalue 123';
execute stmt;
show create sequence s;
Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 123 increment by 1 cache 1000 nocycle ENGINE=MyISAM
execute stmt;
show create sequence s;
Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 123 increment by 1 cache 1000 nocycle ENGINE=MyISAM
deallocate prepare stmt;
drop sequence s;
create sequence s;
show create sequence s;
Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=MyISAM
create procedure p() alter sequence s maxvalue 123;
call p;
show create sequence s;
Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 123 increment by 1 cache 1000 nocycle ENGINE=MyISAM
call p;
show create sequence s;
Table Create Table
s CREATE SEQUENCE `s` start with 1 minvalue 1 maxvalue 123 increment by 1 cache 1000 nocycle ENGINE=MyISAM
drop procedure p;
drop sequence s;
#
# End of 10.4 tests
#
#
# MDEV-31607 ER_DUP_KEY in mysql.table_stats upon REANME on sequence # MDEV-31607 ER_DUP_KEY in mysql.table_stats upon REANME on sequence
# #
CREATE SEQUENCE s1 ENGINE=InnoDB; CREATE SEQUENCE s1 ENGINE=InnoDB;
@@ -266,3 +315,6 @@ s2 CREATE SEQUENCE `s2` start with 1 minvalue 1 maxvalue 9223372036854775806 inc
DROP SEQUENCE s2; DROP SEQUENCE s2;
RENAME TABLE s1 TO s2; RENAME TABLE s1 TO s2;
DROP SEQUENCE s2; DROP SEQUENCE s2;
#
# End of 10.6 tests
#

View File

@@ -167,6 +167,41 @@ ALTER TABLE s ORDER BY cache_size;
SELECT NEXTVAL(s); SELECT NEXTVAL(s);
DROP SEQUENCE s; DROP SEQUENCE s;
--echo #
--echo # MDEV-33169 Alter sequence 2nd ps fails while alter sequence 2nd time (no ps) succeeds
--echo #
create sequence s;
show create sequence s;
alter sequence s maxvalue 123;
show create sequence s;
alter sequence s maxvalue 123;
show create sequence s;
drop sequence s;
create sequence s;
show create sequence s;
prepare stmt from 'alter sequence s maxvalue 123';
execute stmt;
show create sequence s;
execute stmt;
show create sequence s;
deallocate prepare stmt;
drop sequence s;
create sequence s;
show create sequence s;
create procedure p() alter sequence s maxvalue 123;
call p;
show create sequence s;
call p;
show create sequence s;
drop procedure p;
drop sequence s;
--echo #
--echo # End of 10.4 tests
--echo #
--echo # --echo #
--echo # MDEV-31607 ER_DUP_KEY in mysql.table_stats upon REANME on sequence --echo # MDEV-31607 ER_DUP_KEY in mysql.table_stats upon REANME on sequence
--echo # --echo #
@@ -180,3 +215,7 @@ RENAME TABLE s1 TO s2;
DROP SEQUENCE s2; DROP SEQUENCE s2;
--enable_ps2_protocol --enable_ps2_protocol
--echo #
--echo # End of 10.6 tests
--echo #

View File

@@ -786,7 +786,6 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
mysql_mutex_unlock(&LOCK_thread_count); mysql_mutex_unlock(&LOCK_thread_count);
DBUG_PRINT("info",("signal thread created")); DBUG_PRINT("info",("signal thread created"));
thr_setconcurrency(3);
pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_PROCESS); pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_PROCESS);
printf("Main thread: %s\n",my_thread_name()); printf("Main thread: %s\n",my_thread_name());
for (i=0 ; i < 2 ; i++) for (i=0 ; i < 2 ; i++)

View File

@@ -1783,9 +1783,6 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
error,errno); error,errno);
exit(1); exit(1);
} }
#endif
#ifdef HAVE_THR_SETCONCURRENCY
(void) thr_setconcurrency(2);
#endif #endif
for (i=0 ; i < array_elements(lock_counts) ; i++) for (i=0 ; i < array_elements(lock_counts) ; i++)
{ {

View File

@@ -533,7 +533,6 @@ static void run_test()
mysql_mutex_init(0, &LOCK_thread_count, MY_MUTEX_INIT_FAST); mysql_mutex_init(0, &LOCK_thread_count, MY_MUTEX_INIT_FAST);
mysql_cond_init(0, &COND_thread_count, NULL); mysql_cond_init(0, &COND_thread_count, NULL);
thr_setconcurrency(3);
pthread_attr_init(&thr_attr); pthread_attr_init(&thr_attr);
pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_PROCESS); pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_PROCESS);
printf("Main thread: %s\n",my_thread_name()); printf("Main thread: %s\n",my_thread_name());

View File

@@ -10,8 +10,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <security/pam_modules.h>
#include <security/pam_appl.h> #include <security/pam_appl.h>
#include <security/pam_modules.h>
#define N 3 #define N 3

View File

@@ -19,10 +19,14 @@
#include <sys/types.h> #include <sys/types.h>
#if defined(HAVE_GETMNTENT) #if defined(HAVE_GETMNTENT)
#include <mntent.h> #include <mntent.h>
#elif defined(HAVE_SYS_MNTENT)
#include <sys/mntent.h>
#elif !defined(HAVE_GETMNTINFO_TAKES_statvfs) #elif !defined(HAVE_GETMNTINFO_TAKES_statvfs)
/* getmntinfo (the not NetBSD variants) */ /* getmntinfo (the not NetBSD variants) */
#include <sys/param.h> #include <sys/param.h>
#if defined(HAVE_SYS_UCRED)
#include <sys/ucred.h> #include <sys/ucred.h>
#endif
#include <sys/mount.h> #include <sys/mount.h>
#endif #endif
#if defined(HAVE_GETMNTENT_IN_SYS_MNTAB) #if defined(HAVE_GETMNTENT_IN_SYS_MNTAB)

View File

@@ -958,7 +958,8 @@ static my_bool signal_ddl_recovery_done(THD *, plugin_ref plugin, void *)
{ {
handlerton *hton= plugin_hton(plugin); handlerton *hton= plugin_hton(plugin);
if (hton->signal_ddl_recovery_done) if (hton->signal_ddl_recovery_done)
(hton->signal_ddl_recovery_done)(hton); if ((hton->signal_ddl_recovery_done)(hton))
plugin_ref_to_int(plugin)->state= PLUGIN_IS_DELETED;
return 0; return 0;
} }

View File

@@ -1495,7 +1495,7 @@ struct handlerton
const LEX_CUSTRING *version, ulonglong create_id); const LEX_CUSTRING *version, ulonglong create_id);
/* Called for all storage handlers after ddl recovery is done */ /* Called for all storage handlers after ddl recovery is done */
void (*signal_ddl_recovery_done)(handlerton *hton); int (*signal_ddl_recovery_done)(handlerton *hton);
/* /*
Optional clauses in the CREATE/ALTER TABLE Optional clauses in the CREATE/ALTER TABLE

View File

@@ -7041,7 +7041,25 @@ Item *Item_float::neg(THD *thd)
else if (value < 0 && max_length) else if (value < 0 && max_length)
max_length--; max_length--;
value= -value; value= -value;
presentation= 0; if (presentation)
{
if (*presentation == '-')
{
// Strip double minus: -(-1) -> '1' instead of '--1'
presentation++;
}
else
{
size_t presentation_length= strlen(presentation);
if (char *tmp= (char*) thd->alloc(presentation_length + 2))
{
tmp[0]= '-';
// Copy with the trailing '\0'
memcpy(tmp + 1, presentation, presentation_length + 1);
presentation= tmp;
}
}
}
name= null_clex_str; name= null_clex_str;
return this; return this;
} }

View File

@@ -7521,7 +7521,7 @@ Write_rows_log_event::do_before_row_operations(const Slave_reporting_capability
indexed and it cannot have a DEFAULT value). indexed and it cannot have a DEFAULT value).
*/ */
m_table->auto_increment_field_not_null= FALSE; m_table->auto_increment_field_not_null= FALSE;
m_table->mark_auto_increment_column(); m_table->mark_auto_increment_column(true);
} }
return error; return error;

View File

@@ -5221,6 +5221,14 @@ static int init_server_components()
if (!opt_abort && ddl_log_initialize()) if (!opt_abort && ddl_log_initialize())
unireg_abort(1); unireg_abort(1);
/*
Plugins may not be completed because system table DDLs are only
run after the ddl recovery done. Therefore between the
plugin_init() call and the ha_signal_ddl_recovery_done() call
below only things related to preparation for recovery should be
done and nothing else, and definitely not anything assuming that
all plugins have been initialised.
*/
if (plugin_init(&remaining_argc, remaining_argv, if (plugin_init(&remaining_argc, remaining_argv,
(opt_noacl ? PLUGIN_INIT_SKIP_PLUGIN_TABLE : 0) | (opt_noacl ? PLUGIN_INIT_SKIP_PLUGIN_TABLE : 0) |
(opt_abort ? PLUGIN_INIT_SKIP_INITIALIZATION : 0))) (opt_abort ? PLUGIN_INIT_SKIP_INITIALIZATION : 0)))
@@ -5791,8 +5799,6 @@ int mysqld_main(int argc, char **argv)
SYSVAR_AUTOSIZE(my_thread_stack_size, new_thread_stack_size); SYSVAR_AUTOSIZE(my_thread_stack_size, new_thread_stack_size);
} }
(void) thr_setconcurrency(concurrency); // 10 by default
select_thread=pthread_self(); select_thread=pthread_self();
select_thread_in_use=1; select_thread_in_use=1;
@@ -6867,8 +6873,8 @@ struct my_option my_long_options[]=
#endif #endif
}; };
static int show_queries(THD *thd, SHOW_VAR *var, char *buff, static int show_queries(THD *thd, SHOW_VAR *var, void *,
enum enum_var_type scope) system_status_var *, enum_var_type)
{ {
var->type= SHOW_LONGLONG; var->type= SHOW_LONGLONG;
var->value= &thd->query_id; var->value= &thd->query_id;
@@ -6876,16 +6882,16 @@ static int show_queries(THD *thd, SHOW_VAR *var, char *buff,
} }
static int show_net_compression(THD *thd, SHOW_VAR *var, char *buff, static int show_net_compression(THD *thd, SHOW_VAR *var, void *,
enum enum_var_type scope) system_status_var *, enum_var_type)
{ {
var->type= SHOW_MY_BOOL; var->type= SHOW_MY_BOOL;
var->value= &thd->net.compress; var->value= &thd->net.compress;
return 0; return 0;
} }
static int show_starttime(THD *thd, SHOW_VAR *var, char *buff, static int show_starttime(THD *thd, SHOW_VAR *var, void *buff,
enum enum_var_type scope) system_status_var *, enum_var_type)
{ {
var->type= SHOW_LONG; var->type= SHOW_LONG;
var->value= buff; var->value= buff;
@@ -6894,8 +6900,8 @@ static int show_starttime(THD *thd, SHOW_VAR *var, char *buff,
} }
#ifdef ENABLED_PROFILING #ifdef ENABLED_PROFILING
static int show_flushstatustime(THD *thd, SHOW_VAR *var, char *buff, static int show_flushstatustime(THD *thd, SHOW_VAR *var, void *buff,
enum enum_var_type scope) system_status_var *, enum_var_type)
{ {
var->type= SHOW_LONG; var->type= SHOW_LONG;
var->value= buff; var->value= buff;
@@ -6905,32 +6911,28 @@ static int show_flushstatustime(THD *thd, SHOW_VAR *var, char *buff,
#endif #endif
#ifdef HAVE_REPLICATION #ifdef HAVE_REPLICATION
static int show_rpl_status(THD *thd, SHOW_VAR *var, char *buff, static int show_rpl_status(THD *, SHOW_VAR *var, void *, system_status_var *,
enum enum_var_type scope) enum_var_type)
{ {
var->type= SHOW_CHAR; var->type= SHOW_CHAR;
var->value= const_cast<char*>(rpl_status_type[(int)rpl_status]); var->value= const_cast<char*>(rpl_status_type[(int)rpl_status]);
return 0; return 0;
} }
static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff, static int show_slave_running(THD *thd, SHOW_VAR *var, void *buff,
enum enum_var_type scope) system_status_var *, enum_var_type)
{ {
Master_info *mi= NULL; if (Master_info *mi=
bool UNINIT_VAR(tmp); get_master_info(&thd->variables.default_master_connection,
Sql_condition::WARN_LEVEL_NOTE))
var->type= SHOW_MY_BOOL;
var->value= buff;
if ((mi= get_master_info(&thd->variables.default_master_connection,
Sql_condition::WARN_LEVEL_NOTE)))
{ {
tmp= (my_bool) (mi->slave_running == MYSQL_SLAVE_RUN_READING && *((my_bool*) buff)=
mi->rli.slave_running != MYSQL_SLAVE_NOT_RUN); (mi->slave_running == MYSQL_SLAVE_RUN_READING &&
mi->rli.slave_running != MYSQL_SLAVE_NOT_RUN);
mi->release(); mi->release();
var->type= SHOW_MY_BOOL;
var->value= buff;
} }
if (mi)
*((my_bool *)buff)= tmp;
else else
var->type= SHOW_UNDEF; var->type= SHOW_UNDEF;
return 0; return 0;
@@ -6940,7 +6942,8 @@ static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff,
/* How many masters this slave is connected to */ /* How many masters this slave is connected to */
static int show_slaves_running(THD *thd, SHOW_VAR *var, char *buff) static int show_slaves_running(THD *, SHOW_VAR *var, void *buff,
system_status_var *, enum_var_type)
{ {
var->type= SHOW_LONGLONG; var->type= SHOW_LONGLONG;
var->value= buff; var->value= buff;
@@ -6951,19 +6954,17 @@ static int show_slaves_running(THD *thd, SHOW_VAR *var, char *buff)
} }
static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff, static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, void *buff,
enum enum_var_type scope) system_status_var *, enum_var_type)
{ {
Master_info *mi; if (Master_info *mi=
get_master_info(&thd->variables.default_master_connection,
var->type= SHOW_LONGLONG; Sql_condition::WARN_LEVEL_NOTE))
var->value= buff;
if ((mi= get_master_info(&thd->variables.default_master_connection,
Sql_condition::WARN_LEVEL_NOTE)))
{ {
*((longlong *)buff)= mi->received_heartbeats; *((longlong *)buff)= mi->received_heartbeats;
mi->release(); mi->release();
var->type= SHOW_LONGLONG;
var->value= buff;
} }
else else
var->type= SHOW_UNDEF; var->type= SHOW_UNDEF;
@@ -6971,19 +6972,17 @@ static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff,
} }
static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff, static int show_heartbeat_period(THD *thd, SHOW_VAR *var, void *buff,
enum enum_var_type scope) system_status_var *, enum_var_type)
{ {
Master_info *mi; if (Master_info *mi=
get_master_info(&thd->variables.default_master_connection,
var->type= SHOW_CHAR; Sql_condition::WARN_LEVEL_NOTE))
var->value= buff;
if ((mi= get_master_info(&thd->variables.default_master_connection,
Sql_condition::WARN_LEVEL_NOTE)))
{ {
sprintf(buff, "%.3f", mi->heartbeat_period); sprintf(static_cast<char*>(buff), "%.3f", mi->heartbeat_period);
mi->release(); mi->release();
var->type= SHOW_CHAR;
var->value= buff;
} }
else else
var->type= SHOW_UNDEF; var->type= SHOW_UNDEF;
@@ -6993,8 +6992,8 @@ static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff,
#endif /* HAVE_REPLICATION */ #endif /* HAVE_REPLICATION */
static int show_open_tables(THD *thd, SHOW_VAR *var, char *buff, static int show_open_tables(THD *, SHOW_VAR *var, void *buff,
enum enum_var_type scope) system_status_var *, enum_var_type)
{ {
var->type= SHOW_LONG; var->type= SHOW_LONG;
var->value= buff; var->value= buff;
@@ -7002,8 +7001,8 @@ static int show_open_tables(THD *thd, SHOW_VAR *var, char *buff,
return 0; return 0;
} }
static int show_prepared_stmt_count(THD *thd, SHOW_VAR *var, char *buff, static int show_prepared_stmt_count(THD *, SHOW_VAR *var, void *buff,
enum enum_var_type scope) system_status_var *, enum_var_type)
{ {
var->type= SHOW_LONG; var->type= SHOW_LONG;
var->value= buff; var->value= buff;
@@ -7013,8 +7012,8 @@ static int show_prepared_stmt_count(THD *thd, SHOW_VAR *var, char *buff,
return 0; return 0;
} }
static int show_table_definitions(THD *thd, SHOW_VAR *var, char *buff, static int show_table_definitions(THD *, SHOW_VAR *var, void *buff,
enum enum_var_type scope) system_status_var *, enum_var_type)
{ {
var->type= SHOW_LONG; var->type= SHOW_LONG;
var->value= buff; var->value= buff;
@@ -7033,8 +7032,8 @@ static int show_table_definitions(THD *thd, SHOW_VAR *var, char *buff,
inside an Event. inside an Event.
*/ */
static int show_ssl_get_version(THD *thd, SHOW_VAR *var, char *buff, static int show_ssl_get_version(THD *thd, SHOW_VAR *var, void *,
enum enum_var_type scope) system_status_var *, enum_var_type)
{ {
var->type= SHOW_CHAR; var->type= SHOW_CHAR;
if( thd->vio_ok() && thd->net.vio->ssl_arg ) if( thd->vio_ok() && thd->net.vio->ssl_arg )
@@ -7044,8 +7043,8 @@ static int show_ssl_get_version(THD *thd, SHOW_VAR *var, char *buff,
return 0; return 0;
} }
static int show_ssl_get_default_timeout(THD *thd, SHOW_VAR *var, char *buff, static int show_ssl_get_default_timeout(THD *thd, SHOW_VAR *var, void *buff,
enum enum_var_type scope) system_status_var *, enum_var_type)
{ {
var->type= SHOW_LONG; var->type= SHOW_LONG;
var->value= buff; var->value= buff;
@@ -7056,8 +7055,8 @@ static int show_ssl_get_default_timeout(THD *thd, SHOW_VAR *var, char *buff,
return 0; return 0;
} }
static int show_ssl_get_verify_mode(THD *thd, SHOW_VAR *var, char *buff, static int show_ssl_get_verify_mode(THD *thd, SHOW_VAR *var, void *buff,
enum enum_var_type scope) system_status_var *, enum_var_type)
{ {
var->type= SHOW_LONG; var->type= SHOW_LONG;
var->value= buff; var->value= buff;
@@ -7072,8 +7071,8 @@ static int show_ssl_get_verify_mode(THD *thd, SHOW_VAR *var, char *buff,
return 0; return 0;
} }
static int show_ssl_get_verify_depth(THD *thd, SHOW_VAR *var, char *buff, static int show_ssl_get_verify_depth(THD *thd, SHOW_VAR *var, void *buff,
enum enum_var_type scope) system_status_var *, enum_var_type)
{ {
var->type= SHOW_LONG; var->type= SHOW_LONG;
var->value= buff; var->value= buff;
@@ -7085,8 +7084,8 @@ static int show_ssl_get_verify_depth(THD *thd, SHOW_VAR *var, char *buff,
return 0; return 0;
} }
static int show_ssl_get_cipher(THD *thd, SHOW_VAR *var, char *buff, static int show_ssl_get_cipher(THD *thd, SHOW_VAR *var, void *buff,
enum enum_var_type scope) system_status_var *, enum_var_type)
{ {
var->type= SHOW_CHAR; var->type= SHOW_CHAR;
if( thd->vio_ok() && thd->net.vio->ssl_arg ) if( thd->vio_ok() && thd->net.vio->ssl_arg )
@@ -7096,9 +7095,10 @@ static int show_ssl_get_cipher(THD *thd, SHOW_VAR *var, char *buff,
return 0; return 0;
} }
static int show_ssl_get_cipher_list(THD *thd, SHOW_VAR *var, char *buff, static int show_ssl_get_cipher_list(THD *thd, SHOW_VAR *var, void *buf,
enum enum_var_type scope) system_status_var *, enum_var_type)
{ {
char *buff= static_cast<char*>(buf);
var->type= SHOW_CHAR; var->type= SHOW_CHAR;
var->value= buff; var->value= buff;
if (thd->vio_ok() && thd->net.vio->ssl_arg) if (thd->vio_ok() && thd->net.vio->ssl_arg)
@@ -7183,8 +7183,8 @@ end:
*/ */
static int static int
show_ssl_get_server_not_before(THD *thd, SHOW_VAR *var, char *buff, show_ssl_get_server_not_before(THD *thd, SHOW_VAR *var, void *buff,
enum enum_var_type scope) system_status_var *, enum_var_type)
{ {
var->type= SHOW_CHAR; var->type= SHOW_CHAR;
if(thd->vio_ok() && thd->net.vio->ssl_arg) if(thd->vio_ok() && thd->net.vio->ssl_arg)
@@ -7193,7 +7193,7 @@ show_ssl_get_server_not_before(THD *thd, SHOW_VAR *var, char *buff,
X509 *cert= SSL_get_certificate(ssl); X509 *cert= SSL_get_certificate(ssl);
const ASN1_TIME *not_before= X509_get0_notBefore(cert); const ASN1_TIME *not_before= X509_get0_notBefore(cert);
var->value= my_asn1_time_to_string(not_before, buff, var->value= my_asn1_time_to_string(not_before, static_cast<char*>(buff),
SHOW_VAR_FUNC_BUFF_SIZE); SHOW_VAR_FUNC_BUFF_SIZE);
if (!var->value) if (!var->value)
return 1; return 1;
@@ -7217,8 +7217,8 @@ show_ssl_get_server_not_before(THD *thd, SHOW_VAR *var, char *buff,
*/ */
static int static int
show_ssl_get_server_not_after(THD *thd, SHOW_VAR *var, char *buff, show_ssl_get_server_not_after(THD *thd, SHOW_VAR *var, void *buff,
enum enum_var_type scope) system_status_var *, enum_var_type)
{ {
var->type= SHOW_CHAR; var->type= SHOW_CHAR;
if(thd->vio_ok() && thd->net.vio->ssl_arg) if(thd->vio_ok() && thd->net.vio->ssl_arg)
@@ -7227,7 +7227,7 @@ show_ssl_get_server_not_after(THD *thd, SHOW_VAR *var, char *buff,
X509 *cert= SSL_get_certificate(ssl); X509 *cert= SSL_get_certificate(ssl);
const ASN1_TIME *not_after= X509_get0_notAfter(cert); const ASN1_TIME *not_after= X509_get0_notAfter(cert);
var->value= my_asn1_time_to_string(not_after, buff, var->value= my_asn1_time_to_string(not_after, static_cast<char*>(buff),
SHOW_VAR_FUNC_BUFF_SIZE); SHOW_VAR_FUNC_BUFF_SIZE);
if (!var->value) if (!var->value)
return 1; return 1;
@@ -7281,7 +7281,7 @@ static int show_default_keycache(THD *thd, SHOW_VAR *var, void *buff,
} }
static int show_memory_used(THD *thd, SHOW_VAR *var, char *buff, static int show_memory_used(THD *thd, SHOW_VAR *var, void *buff,
struct system_status_var *status_var, struct system_status_var *status_var,
enum enum_var_type scope) enum enum_var_type scope)
{ {
@@ -7337,8 +7337,8 @@ static int debug_status_func(THD *thd, SHOW_VAR *var, void *buff,
#endif #endif
#ifdef HAVE_POOL_OF_THREADS #ifdef HAVE_POOL_OF_THREADS
static int show_threadpool_idle_threads(THD *thd, SHOW_VAR *var, char *buff, static int show_threadpool_idle_threads(THD *, SHOW_VAR *var, void *buff,
enum enum_var_type scope) system_status_var *, enum_var_type)
{ {
var->type= SHOW_INT; var->type= SHOW_INT;
var->value= buff; var->value= buff;
@@ -7347,8 +7347,8 @@ static int show_threadpool_idle_threads(THD *thd, SHOW_VAR *var, char *buff,
} }
static int show_threadpool_threads(THD *thd, SHOW_VAR *var, char *buff, static int show_threadpool_threads(THD *, SHOW_VAR *var, void *buff,
enum enum_var_type scope) system_status_var *, enum_var_type)
{ {
var->type= SHOW_INT; var->type= SHOW_INT;
var->value= buff; var->value= buff;

View File

@@ -8395,11 +8395,6 @@ bool check_grant(THD *thd, privilege_t want_access, TABLE_LIST *tables,
INSERT_ACL : SELECT_ACL); INSERT_ACL : SELECT_ACL);
} }
if (tl->with || !tl->db.str ||
(tl->select_lex &&
(tl->with= tl->select_lex->find_table_def_in_with_clauses(tl))))
continue;
const ACL_internal_table_access *access= const ACL_internal_table_access *access=
get_cached_table_access(&t_ref->grant.m_internal, get_cached_table_access(&t_ref->grant.m_internal,
t_ref->get_db_name(), t_ref->get_db_name(),
@@ -12181,8 +12176,8 @@ static my_bool count_column_grants(void *grant_table,
This must be performed under the mutex in order to make sure the This must be performed under the mutex in order to make sure the
iteration does not fail. iteration does not fail.
*/ */
static int show_column_grants(THD *thd, SHOW_VAR *var, char *buff, static int show_column_grants(THD *thd, SHOW_VAR *var, void *buff,
enum enum_var_type scope) system_status_var *, enum enum_var_type scope)
{ {
var->type= SHOW_ULONG; var->type= SHOW_ULONG;
var->value= buff; var->value= buff;
@@ -12198,8 +12193,8 @@ static int show_column_grants(THD *thd, SHOW_VAR *var, char *buff,
return 0; return 0;
} }
static int show_database_grants(THD *thd, SHOW_VAR *var, char *buff, static int show_database_grants(THD *thd, SHOW_VAR *var, void *buff,
enum enum_var_type scope) system_status_var *, enum enum_var_type scope)
{ {
var->type= SHOW_UINT; var->type= SHOW_UINT;
var->value= buff; var->value= buff;

View File

@@ -727,7 +727,6 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
wsrep_wfc() wsrep_wfc()
#endif /*WITH_WSREP */ #endif /*WITH_WSREP */
{ {
ulong tmp;
bzero(&variables, sizeof(variables)); bzero(&variables, sizeof(variables));
/* /*
@@ -879,14 +878,6 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
tablespace_op=FALSE; tablespace_op=FALSE;
/*
Initialize the random generator. We call my_rnd() without a lock as
it's not really critical if two threads modifies the structure at the
same time. We ensure that we have an unique number foreach thread
by adding the address of the stack.
*/
tmp= (ulong) (my_rnd(&sql_rand) * 0xffffffff);
my_rnd_init(&rand, tmp + (ulong)((size_t) &rand), tmp + (ulong) ::global_query_id);
substitute_null_with_insert_id = FALSE; substitute_null_with_insert_id = FALSE;
lock_info.mysql_thd= (void *)this; lock_info.mysql_thd= (void *)this;
@@ -1314,6 +1305,17 @@ void THD::init()
/* Set to handle counting of aborted connections */ /* Set to handle counting of aborted connections */
userstat_running= opt_userstat_running; userstat_running= opt_userstat_running;
last_global_update_time= current_connect_time= time(NULL); last_global_update_time= current_connect_time= time(NULL);
/*
Initialize the random generator. We call my_rnd() without a lock as
it's not really critical if two threads modify the structure at the
same time. We ensure that we have a unique number for each thread
by adding the address of this THD.
*/
ulong tmp= (ulong) (my_rnd(&sql_rand) * 0xffffffff);
my_rnd_init(&rand, tmp + (ulong)(intptr) this,
(ulong)(my_timer_cycles() + global_query_id));
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
session_tracker.enable(this); session_tracker.enable(this);
#endif //EMBEDDED_LIBRARY #endif //EMBEDDED_LIBRARY

View File

@@ -106,6 +106,7 @@ bool LEX::check_dependencies_in_with_clauses()
@param tables Points to the beginning of the sub-chain @param tables Points to the beginning of the sub-chain
@param tables_last Points to the address with the sub-chain barrier @param tables_last Points to the address with the sub-chain barrier
@param excl_spec Ignore the definition with this spec
@details @details
The method resolves tables references to CTE from the chain of The method resolves tables references to CTE from the chain of
@@ -147,7 +148,8 @@ bool LEX::check_dependencies_in_with_clauses()
*/ */
bool LEX::resolve_references_to_cte(TABLE_LIST *tables, bool LEX::resolve_references_to_cte(TABLE_LIST *tables,
TABLE_LIST **tables_last) TABLE_LIST **tables_last,
st_select_lex_unit *excl_spec)
{ {
With_element *with_elem= 0; With_element *with_elem= 0;
@@ -156,7 +158,8 @@ bool LEX::resolve_references_to_cte(TABLE_LIST *tables,
if (tbl->derived) if (tbl->derived)
continue; continue;
if (!tbl->db.str && !tbl->with) if (!tbl->db.str && !tbl->with)
tbl->with= tbl->select_lex->find_table_def_in_with_clauses(tbl); tbl->with= tbl->select_lex->find_table_def_in_with_clauses(tbl,
excl_spec);
if (!tbl->with) // no CTE matches table reference tbl if (!tbl->with) // no CTE matches table reference tbl
{ {
if (only_cte_resolution) if (only_cte_resolution)
@@ -244,7 +247,7 @@ LEX::check_cte_dependencies_and_resolve_references()
return true; return true;
if (!with_cte_resolution) if (!with_cte_resolution)
return false; return false;
if (resolve_references_to_cte(query_tables, query_tables_last)) if (resolve_references_to_cte(query_tables, query_tables_last, NULL))
return true; return true;
return false; return false;
} }
@@ -388,6 +391,7 @@ bool With_element::check_dependencies_in_spec()
@param table The reference to the table that is looked for @param table The reference to the table that is looked for
@param barrier The barrier with element for the search @param barrier The barrier with element for the search
@param excl_spec Ignore the definition with this spec
@details @details
The function looks through the elements of this with clause trying to find The function looks through the elements of this with clause trying to find
@@ -401,12 +405,15 @@ bool With_element::check_dependencies_in_spec()
*/ */
With_element *With_clause::find_table_def(TABLE_LIST *table, With_element *With_clause::find_table_def(TABLE_LIST *table,
With_element *barrier) With_element *barrier,
st_select_lex_unit *excl_spec)
{ {
for (With_element *with_elem= with_list.first; for (With_element *with_elem= with_list.first;
with_elem != barrier; with_elem != barrier;
with_elem= with_elem->next) with_elem= with_elem->next)
{ {
if (excl_spec && with_elem->spec == excl_spec)
continue;
if (my_strcasecmp(system_charset_info, with_elem->get_name_str(), if (my_strcasecmp(system_charset_info, with_elem->get_name_str(),
table->table_name.str) == 0 && table->table_name.str) == 0 &&
!table->is_fqtn) !table->is_fqtn)
@@ -466,7 +473,7 @@ With_element *find_table_def_in_with_clauses(TABLE_LIST *tbl,
top_unit->with_element && top_unit->with_element &&
top_unit->with_element->get_owner() == with_clause) top_unit->with_element->get_owner() == with_clause)
barrier= top_unit->with_element; barrier= top_unit->with_element;
found= with_clause->find_table_def(tbl, barrier); found= with_clause->find_table_def(tbl, barrier, NULL);
if (found) if (found)
break; break;
} }
@@ -521,10 +528,11 @@ void With_element::check_dependencies_in_select(st_select_lex *sl,
{ {
With_clause *with_clause= sl->master_unit()->with_clause; With_clause *with_clause= sl->master_unit()->with_clause;
if (with_clause) if (with_clause)
tbl->with= with_clause->find_table_def(tbl, NULL); tbl->with= with_clause->find_table_def(tbl, NULL, NULL);
if (!tbl->with) if (!tbl->with)
tbl->with= owner->find_table_def(tbl, tbl->with= owner->find_table_def(tbl,
owner->with_recursive ? NULL : this); owner->with_recursive ? NULL : this,
NULL);
} }
if (!tbl->with) if (!tbl->with)
tbl->with= find_table_def_in_with_clauses(tbl, ctxt); tbl->with= find_table_def_in_with_clauses(tbl, ctxt);
@@ -1101,7 +1109,8 @@ st_select_lex_unit *With_element::clone_parsed_spec(LEX *old_lex,
*/ */
lex->only_cte_resolution= old_lex->only_cte_resolution; lex->only_cte_resolution= old_lex->only_cte_resolution;
if (lex->resolve_references_to_cte(lex->query_tables, if (lex->resolve_references_to_cte(lex->query_tables,
lex->query_tables_last)) lex->query_tables_last,
spec))
{ {
res= NULL; res= NULL;
goto err; goto err;
@@ -1304,6 +1313,7 @@ bool With_element::is_anchor(st_select_lex *sel)
Search for the definition of the given table referred in this select node Search for the definition of the given table referred in this select node
@param table reference to the table whose definition is searched for @param table reference to the table whose definition is searched for
@param excl_spec ignore the definition with this spec
@details @details
The method looks for the definition of the table whose reference is occurred The method looks for the definition of the table whose reference is occurred
@@ -1316,7 +1326,8 @@ bool With_element::is_anchor(st_select_lex *sel)
NULL - otherwise NULL - otherwise
*/ */
With_element *st_select_lex::find_table_def_in_with_clauses(TABLE_LIST *table) With_element *st_select_lex::find_table_def_in_with_clauses(TABLE_LIST *table,
st_select_lex_unit *excl_spec)
{ {
With_element *found= NULL; With_element *found= NULL;
With_clause *containing_with_clause= NULL; With_clause *containing_with_clause= NULL;
@@ -1333,7 +1344,7 @@ With_element *st_select_lex::find_table_def_in_with_clauses(TABLE_LIST *table)
With_clause *attached_with_clause= sl->get_with_clause(); With_clause *attached_with_clause= sl->get_with_clause();
if (attached_with_clause && if (attached_with_clause &&
attached_with_clause != containing_with_clause && attached_with_clause != containing_with_clause &&
(found= attached_with_clause->find_table_def(table, NULL))) (found= attached_with_clause->find_table_def(table, NULL, excl_spec)))
break; break;
master_unit= sl->master_unit(); master_unit= sl->master_unit();
outer_sl= master_unit->outer_select(); outer_sl= master_unit->outer_select();
@@ -1343,7 +1354,8 @@ With_element *st_select_lex::find_table_def_in_with_clauses(TABLE_LIST *table)
containing_with_clause= with_elem->get_owner(); containing_with_clause= with_elem->get_owner();
With_element *barrier= containing_with_clause->with_recursive ? With_element *barrier= containing_with_clause->with_recursive ?
NULL : with_elem; NULL : with_elem;
if ((found= containing_with_clause->find_table_def(table, barrier))) if ((found= containing_with_clause->find_table_def(table, barrier,
excl_spec)))
break; break;
if (outer_sl && !outer_sl->get_with_element()) if (outer_sl && !outer_sl->get_with_element())
break; break;

View File

@@ -325,7 +325,8 @@ public:
friend friend
bool LEX::resolve_references_to_cte(TABLE_LIST *tables, bool LEX::resolve_references_to_cte(TABLE_LIST *tables,
TABLE_LIST **tables_last); TABLE_LIST **tables_last,
st_select_lex_unit *excl_spec);
}; };
const uint max_number_of_elements_in_with_clause= sizeof(table_map)*8; const uint max_number_of_elements_in_with_clause= sizeof(table_map)*8;
@@ -425,7 +426,8 @@ public:
void move_anchors_ahead(); void move_anchors_ahead();
With_element *find_table_def(TABLE_LIST *table, With_element *barrier); With_element *find_table_def(TABLE_LIST *table, With_element *barrier,
st_select_lex_unit *excl_spec);
With_element *find_table_def_in_with_clauses(TABLE_LIST *table); With_element *find_table_def_in_with_clauses(TABLE_LIST *table);

View File

@@ -1594,7 +1594,8 @@ public:
master_unit()->cloned_from->with_element : master_unit()->cloned_from->with_element :
master_unit()->with_element; master_unit()->with_element;
} }
With_element *find_table_def_in_with_clauses(TABLE_LIST *table); With_element *find_table_def_in_with_clauses(TABLE_LIST *table,
st_select_lex_unit * excl_spec);
bool check_unrestricted_recursive(bool only_standard_compliant); bool check_unrestricted_recursive(bool only_standard_compliant);
bool check_subqueries_with_recursive_references(); bool check_subqueries_with_recursive_references();
void collect_grouping_fields_for_derived(THD *thd, ORDER *grouping_list); void collect_grouping_fields_for_derived(THD *thd, ORDER *grouping_list);
@@ -4890,7 +4891,8 @@ public:
bool check_dependencies_in_with_clauses(); bool check_dependencies_in_with_clauses();
bool check_cte_dependencies_and_resolve_references(); bool check_cte_dependencies_and_resolve_references();
bool resolve_references_to_cte(TABLE_LIST *tables, bool resolve_references_to_cte(TABLE_LIST *tables,
TABLE_LIST **tables_last); TABLE_LIST **tables_last,
st_select_lex_unit *excl_spec);
/** /**
Turn on the SELECT_DESCRIBE flag for every SELECT_LEX involved into Turn on the SELECT_DESCRIBE flag for every SELECT_LEX involved into

View File

@@ -921,6 +921,7 @@ bool Sql_cmd_alter_sequence::execute(THD *thd)
TABLE_LIST *first_table= lex->query_tables; TABLE_LIST *first_table= lex->query_tables;
TABLE *table; TABLE *table;
sequence_definition *new_seq= lex->create_info.seq_create_info; sequence_definition *new_seq= lex->create_info.seq_create_info;
uint saved_used_fields= new_seq->used_fields;
SEQUENCE *seq; SEQUENCE *seq;
No_such_table_error_handler no_such_table_handler; No_such_table_error_handler no_such_table_handler;
DBUG_ENTER("Sql_cmd_alter_sequence::execute"); DBUG_ENTER("Sql_cmd_alter_sequence::execute");
@@ -1042,5 +1043,6 @@ bool Sql_cmd_alter_sequence::execute(THD *thd)
my_ok(thd); my_ok(thd);
end: end:
new_seq->used_fields= saved_used_fields;
DBUG_RETURN(error); DBUG_RETURN(error);
} }

View File

@@ -297,7 +297,8 @@ bool create_view_precheck(THD *thd, TABLE_LIST *tables, TABLE_LIST *view,
for (tbl= sl->get_table_list(); tbl; tbl= tbl->next_local) for (tbl= sl->get_table_list(); tbl; tbl= tbl->next_local)
{ {
if (!tbl->with && tbl->select_lex) if (!tbl->with && tbl->select_lex)
tbl->with= tbl->select_lex->find_table_def_in_with_clauses(tbl); tbl->with= tbl->select_lex->find_table_def_in_with_clauses(tbl,
NULL);
/* /*
Ensure that we have some privileges on this table, more strict check Ensure that we have some privileges on this table, more strict check
will be done on column level after preparation, will be done on column level after preparation,

View File

@@ -7585,7 +7585,7 @@ inline void TABLE::mark_index_columns_for_read(uint index)
always set and sometimes read. always set and sometimes read.
*/ */
void TABLE::mark_auto_increment_column() void TABLE::mark_auto_increment_column(bool is_insert)
{ {
DBUG_ASSERT(found_next_number_field); DBUG_ASSERT(found_next_number_field);
/* /*
@@ -7593,7 +7593,8 @@ void TABLE::mark_auto_increment_column()
store() to check overflow of auto_increment values store() to check overflow of auto_increment values
*/ */
bitmap_set_bit(read_set, found_next_number_field->field_index); bitmap_set_bit(read_set, found_next_number_field->field_index);
bitmap_set_bit(write_set, found_next_number_field->field_index); if (is_insert)
bitmap_set_bit(write_set, found_next_number_field->field_index);
if (s->next_number_keypart) if (s->next_number_keypart)
mark_index_columns_for_read(s->next_number_index); mark_index_columns_for_read(s->next_number_index);
file->column_bitmaps_signal(); file->column_bitmaps_signal();
@@ -7718,7 +7719,7 @@ void TABLE::mark_columns_needed_for_update()
else else
{ {
if (found_next_number_field) if (found_next_number_field)
mark_auto_increment_column(); mark_auto_increment_column(false);
} }
if (file->ha_table_flags() & HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) if (file->ha_table_flags() & HA_PRIMARY_KEY_REQUIRED_FOR_DELETE)
@@ -7794,7 +7795,7 @@ void TABLE::mark_columns_needed_for_insert()
triggers->mark_fields_used(TRG_EVENT_INSERT); triggers->mark_fields_used(TRG_EVENT_INSERT);
} }
if (found_next_number_field) if (found_next_number_field)
mark_auto_increment_column(); mark_auto_increment_column(true);
if (default_field) if (default_field)
mark_default_fields_for_write(TRUE); mark_default_fields_for_write(TRUE);
if (s->versioned) if (s->versioned)

View File

@@ -1585,7 +1585,7 @@ public:
void mark_index_columns_no_reset(uint index, MY_BITMAP *bitmap); void mark_index_columns_no_reset(uint index, MY_BITMAP *bitmap);
void mark_index_columns_for_read(uint index); void mark_index_columns_for_read(uint index);
void restore_column_maps_after_keyread(MY_BITMAP *backup); void restore_column_maps_after_keyread(MY_BITMAP *backup);
void mark_auto_increment_column(void); void mark_auto_increment_column(bool insert_fl);
void mark_columns_needed_for_update(void); void mark_columns_needed_for_update(void);
void mark_columns_needed_for_delete(void); void mark_columns_needed_for_delete(void);
void mark_columns_needed_for_insert(void); void mark_columns_needed_for_insert(void);

View File

@@ -1213,8 +1213,8 @@ int tdc_iterate(THD *thd, my_hash_walk_action action, void *argument,
} }
int show_tc_active_instances(THD *thd, SHOW_VAR *var, char *buff, int show_tc_active_instances(THD *thd, SHOW_VAR *var, void *buff,
enum enum_var_type scope) system_status_var *, enum enum_var_type scope)
{ {
var->type= SHOW_UINT; var->type= SHOW_UINT;
var->value= buff; var->value= buff;

View File

@@ -87,8 +87,8 @@ extern int tdc_iterate(THD *thd, my_hash_walk_action action, void *argument,
bool no_dups= false); bool no_dups= false);
extern uint tc_records(void); extern uint tc_records(void);
int show_tc_active_instances(THD *thd, SHOW_VAR *var, char *buff, int show_tc_active_instances(THD *thd, SHOW_VAR *var, void *buff,
enum enum_var_type scope); system_status_var *, enum enum_var_type scope);
extern void tc_purge(); extern void tc_purge();
extern void tc_add_table(THD *thd, TABLE *table); extern void tc_add_table(THD *thd, TABLE *table);
extern void tc_release_table(TABLE *table); extern void tc_release_table(TABLE *table);

View File

@@ -71,11 +71,6 @@
#include "tabvct.h" #include "tabvct.h"
#include "valblk.h" #include "valblk.h"
#if defined(UNIX)
//add dummy strerror (NGC)
char *strerror(int num);
#endif // UNIX
/***********************************************************************/ /***********************************************************************/
/* External function. */ /* External function. */
/***********************************************************************/ /***********************************************************************/

View File

@@ -2087,7 +2087,7 @@ all_fail:
ut_d(purge_sys.resume_FTS()); ut_d(purge_sys.resume_FTS());
} }
static void innodb_ddl_recovery_done(handlerton*) static int innodb_ddl_recovery_done(handlerton*)
{ {
ut_ad(!ddl_recovery_done); ut_ad(!ddl_recovery_done);
ut_d(ddl_recovery_done= true); ut_d(ddl_recovery_done= true);
@@ -2098,6 +2098,7 @@ static void innodb_ddl_recovery_done(handlerton*)
drop_garbage_tables_after_restore(); drop_garbage_tables_after_restore();
srv_init_purge_tasks(); srv_init_purge_tasks();
} }
return 0;
} }
/********************************************************************//** /********************************************************************//**

View File

@@ -140,6 +140,15 @@ private:
bool m_initialized{false}; bool m_initialized{false};
/** whether purge is enabled; protected by latch and std::atomic */ /** whether purge is enabled; protected by latch and std::atomic */
std::atomic<bool> m_enabled{false}; std::atomic<bool> m_enabled{false};
/** The primary candidate for iterator::free_history() is
rseg=trx_sys.rseg_array[skipped_rseg]. This field may be changed
after invoking rseg.set_skip_allocation() and rseg.clear_skip_allocation()
and while holding the exclusive rseg.latch.
This may only be 0 if innodb_undo_tablespaces=0, because rollback segment
0 always resides in the system tablespace and would never be used when
dedicated undo tablespaces are in use. */
Atomic_relaxed<uint8_t> skipped_rseg;
public: public:
/** whether purge is active (may hold table handles) */ /** whether purge is active (may hold table handles) */
std::atomic<bool> m_active{false}; std::atomic<bool> m_active{false};
@@ -197,6 +206,11 @@ public:
return undo_no <= other.undo_no; return undo_no <= other.undo_no;
} }
/** Remove unnecessary history data from a rollback segment.
@param rseg rollback segment
@return error code */
inline dberr_t free_history_rseg(trx_rseg_t &rseg) const;
/** Free the undo pages up to this. */ /** Free the undo pages up to this. */
dberr_t free_history() const; dberr_t free_history() const;
@@ -240,14 +254,15 @@ public:
by the pq_mutex */ by the pq_mutex */
mysql_mutex_t pq_mutex; /*!< Mutex protecting purge_queue */ mysql_mutex_t pq_mutex; /*!< Mutex protecting purge_queue */
/** Undo tablespace file truncation (only accessed by the /** innodb_undo_log_truncate=ON state;
srv_purge_coordinator_thread) */ only modified by purge_coordinator_callback() */
struct { struct {
/** The undo tablespace that is currently being truncated */ /** The undo tablespace that is currently being truncated */
fil_space_t* current; Atomic_relaxed<fil_space_t*> current;
/** The undo tablespace that was last truncated */ /** The number of the undo tablespace that was last truncated,
fil_space_t* last; relative from srv_undo_space_id_start */
} truncate; uint32_t last;
} truncate_undo_space;
/** Create the instance */ /** Create the instance */
void create(); void create();
@@ -357,6 +372,26 @@ public:
typically via purge_sys_t::view_guard. */ typically via purge_sys_t::view_guard. */
return view.sees(id); return view.sees(id);
} }
private:
/** Enable the use of a rollback segment and advance skipped_rseg,
after iterator::free_history_rseg() had invoked
rseg.set_skip_allocation(). */
inline void rseg_enable(trx_rseg_t &rseg);
/** Try to start truncating a tablespace.
@param id undo tablespace identifier
@param size the maximum desired undo tablespace size, in pages
@return undo tablespace whose truncation was started
@retval nullptr if truncation is not currently possible */
inline fil_space_t *undo_truncate_try(uint32_t id, uint32_t size);
public:
/** Check if innodb_undo_log_truncate=ON needs to be handled.
This is only to be called by purge_coordinator_callback().
@return undo tablespace chosen by innodb_undo_log_truncate=ON
@retval nullptr if truncation is not currently possible */
fil_space_t *truncating_tablespace();
/** A wrapper around trx_sys_t::clone_oldest_view(). */ /** A wrapper around trx_sys_t::clone_oldest_view(). */
template<bool also_end_view= false> template<bool also_end_view= false>
void clone_oldest_view() void clone_oldest_view()

View File

@@ -73,14 +73,15 @@ private:
/** Reference counter to track is_persistent() transactions, /** Reference counter to track is_persistent() transactions,
with SKIP flag. */ with SKIP flag. */
std::atomic<uint32_t> ref; std::atomic<uint32_t> ref;
public:
/** Whether undo tablespace truncation is pending */ /** Whether undo tablespace truncation is pending */
static constexpr uint32_t SKIP= 1; static constexpr uint32_t SKIP= 1;
/** Transaction reference count multiplier */ /** Transaction reference count multiplier */
static constexpr uint32_t REF= 2; static constexpr uint32_t REF= 2;
/** @return the reference count and flags */
uint32_t ref_load() const { return ref.load(std::memory_order_relaxed); } uint32_t ref_load() const { return ref.load(std::memory_order_relaxed); }
private:
/** Set the SKIP bit */ /** Set the SKIP bit */
void ref_set_skip() void ref_set_skip()
{ {

View File

@@ -1191,6 +1191,11 @@ public:
return count; return count;
} }
/** Disable further allocation of transactions in a rollback segment
that are subject to innodb_undo_log_truncate=ON
@param space undo tablespace that will be truncated */
inline void undo_truncate_start(fil_space_t &space);
/** Set the undo log empty value */ /** Set the undo log empty value */
void set_undo_non_empty(bool val) void set_undo_non_empty(bool val)
{ {

View File

@@ -1503,7 +1503,8 @@ inline void purge_coordinator_state::do_purge()
ulint n_pages_handled= trx_purge(n_threads, history_size); ulint n_pages_handled= trx_purge(n_threads, history_size);
if (!trx_sys.history_exists()) if (!trx_sys.history_exists())
goto no_history; goto no_history;
if (purge_sys.truncate.current || srv_shutdown_state != SRV_SHUTDOWN_NONE) if (purge_sys.truncating_tablespace() ||
srv_shutdown_state != SRV_SHUTDOWN_NONE)
{ {
purge_truncation_task.wait(); purge_truncation_task.wait();
trx_purge_truncate_history(); trx_purge_truncate_history();

View File

@@ -169,10 +169,15 @@ void purge_sys_t::create()
ut_ad(this == &purge_sys); ut_ad(this == &purge_sys);
ut_ad(!m_initialized); ut_ad(!m_initialized);
ut_ad(!enabled()); ut_ad(!enabled());
ut_ad(!m_active);
/* If innodb_undo_tablespaces>0, the rollback segment 0
(which always resides in the system tablespace) will
never be used; @see trx_assign_rseg_low() */
skipped_rseg= srv_undo_tablespaces > 0;
m_paused= 0; m_paused= 0;
query= purge_graph_build(); query= purge_graph_build();
next_stored= false; next_stored= false;
rseg= NULL; rseg= nullptr;
page_no= 0; page_no= 0;
offset= 0; offset= 0;
hdr_page_no= 0; hdr_page_no= 0;
@@ -180,8 +185,8 @@ void purge_sys_t::create()
latch.SRW_LOCK_INIT(trx_purge_latch_key); latch.SRW_LOCK_INIT(trx_purge_latch_key);
end_latch.init(); end_latch.init();
mysql_mutex_init(purge_sys_pq_mutex_key, &pq_mutex, nullptr); mysql_mutex_init(purge_sys_pq_mutex_key, &pq_mutex, nullptr);
truncate.current= NULL; truncate_undo_space.current= nullptr;
truncate.last= NULL; truncate_undo_space.last= 0;
m_initialized= true; m_initialized= true;
} }
@@ -388,17 +393,50 @@ static void trx_purge_free_segment(buf_block_t *rseg_hdr, buf_block_t *block,
block->page.frame, &mtr)); block->page.frame, &mtr));
} }
void purge_sys_t::rseg_enable(trx_rseg_t &rseg)
{
ut_ad(this == &purge_sys);
#ifndef SUX_LOCK_GENERIC
ut_ad(rseg.latch.is_write_locked());
#endif
uint8_t skipped= skipped_rseg;
ut_ad(skipped < TRX_SYS_N_RSEGS);
if (&rseg == &trx_sys.rseg_array[skipped])
{
/* If this rollback segment is subject to innodb_undo_log_truncate=ON,
we must not clear the flag. But we will advance purge_sys.skipped_rseg
to be able to choose another candidate for this soft truncation, and
to prevent the following scenario:
(1) purge_sys_t::iterator::free_history_rseg() had invoked
rseg.set_skip_allocation()
(2) undo log truncation had completed on this rollback segment
(3) SET GLOBAL innodb_undo_log_truncate=OFF
(4) purge_sys_t::iterator::free_history_rseg() would not be able to
invoke rseg.set_skip_allocation() on any other rollback segment
before this rseg has grown enough */
if (truncate_undo_space.current != rseg.space)
rseg.clear_skip_allocation();
skipped++;
/* If innodb_undo_tablespaces>0, the rollback segment 0
(which always resides in the system tablespace) will
never be used; @see trx_assign_rseg_low() */
if (!(skipped%= TRX_SYS_N_RSEGS) && srv_undo_tablespaces)
skipped++;
skipped_rseg= skipped;
}
}
/** Remove unnecessary history data from a rollback segment. /** Remove unnecessary history data from a rollback segment.
@param rseg rollback segment @param rseg rollback segment
@param limit truncate anything before this @param limit truncate anything before this
@param all whether everything can be truncated
@return error code */ @return error code */
static dberr_t inline dberr_t purge_sys_t::iterator::free_history_rseg(trx_rseg_t &rseg) const
trx_purge_truncate_rseg_history(trx_rseg_t &rseg,
const purge_sys_t::iterator &limit, bool all)
{ {
fil_addr_t hdr_addr; fil_addr_t hdr_addr;
mtr_t mtr; mtr_t mtr;
bool freed= false;
uint32_t rseg_ref= 0;
mtr.start(); mtr.start();
@@ -408,6 +446,8 @@ trx_purge_truncate_rseg_history(trx_rseg_t &rseg,
{ {
func_exit: func_exit:
mtr.commit(); mtr.commit();
if (freed && (rseg.SKIP & rseg_ref))
purge_sys.rseg_enable(rseg);
return err; return err;
} }
@@ -429,16 +469,40 @@ loop:
const trx_id_t undo_trx_no= const trx_id_t undo_trx_no=
mach_read_from_8(b->page.frame + hdr_addr.boffset + TRX_UNDO_TRX_NO); mach_read_from_8(b->page.frame + hdr_addr.boffset + TRX_UNDO_TRX_NO);
if (undo_trx_no >= limit.trx_no) if (undo_trx_no >= trx_no)
{ {
if (undo_trx_no == limit.trx_no) if (undo_trx_no == trx_no)
err = trx_undo_truncate_start(&rseg, hdr_addr.page, err= trx_undo_truncate_start(&rseg, hdr_addr.page,
hdr_addr.boffset, limit.undo_no); hdr_addr.boffset, undo_no);
goto func_exit; goto func_exit;
} }
else
{
rseg_ref= rseg.ref_load();
if (rseg_ref >= rseg.REF || !purge_sys.sees(rseg.needs_purge))
{
/* We cannot clear this entire rseg because trx_assign_rseg_low()
has already chosen it for a future trx_undo_assign(), or
because some recently started transaction needs purging.
if (!all) If this invocation could not reduce rseg.history_size at all
goto func_exit; (!freed), we will try to ensure progress and prevent our
starvation by disabling one rollback segment for future
trx_assign_rseg_low() invocations until a future invocation has
made progress and invoked purge_sys_t::rseg_enable(rseg) on that
rollback segment. */
if (!(rseg.SKIP & rseg_ref) && !freed &&
ut_d(!trx_rseg_n_slots_debug &&)
&rseg == &trx_sys.rseg_array[purge_sys.skipped_rseg])
/* If rseg.space == purge_sys.truncate_undo_space.current
the following will be a no-op. A possible conflict
with innodb_undo_log_truncate=ON will be handled in
purge_sys_t::rseg_enable(). */
rseg.set_skip_allocation();
goto func_exit;
}
}
fil_addr_t prev_hdr_addr= fil_addr_t prev_hdr_addr=
flst_get_prev_addr(b->page.frame + hdr_addr.boffset + flst_get_prev_addr(b->page.frame + hdr_addr.boffset +
@@ -501,6 +565,7 @@ loop:
mtr.commit(); mtr.commit();
ut_ad(rseg.history_size > 0); ut_ad(rseg.history_size > 0);
rseg.history_size--; rseg.history_size--;
freed= true;
mtr.start(); mtr.start();
rseg_hdr->page.lock.x_lock(); rseg_hdr->page.lock.x_lock();
ut_ad(rseg_hdr->page.id() == rseg.page_id()); ut_ad(rseg_hdr->page.id() == rseg.page_id());
@@ -555,9 +620,7 @@ dberr_t purge_sys_t::iterator::free_history() const
ut_ad(rseg.is_persistent()); ut_ad(rseg.is_persistent());
log_free_check(); log_free_check();
rseg.latch.wr_lock(SRW_LOCK_CALL); rseg.latch.wr_lock(SRW_LOCK_CALL);
dberr_t err= dberr_t err= free_history_rseg(rseg);
trx_purge_truncate_rseg_history(rseg, *this, !rseg.is_referenced() &&
purge_sys.sees(rseg.needs_purge));
rseg.latch.wr_unlock(); rseg.latch.wr_unlock();
if (err) if (err)
return err; return err;
@@ -565,6 +628,62 @@ dberr_t purge_sys_t::iterator::free_history() const
return DB_SUCCESS; return DB_SUCCESS;
} }
inline void trx_sys_t::undo_truncate_start(fil_space_t &space)
{
ut_ad(this == &trx_sys);
/* Undo tablespace always are a single file. */
ut_a(UT_LIST_GET_LEN(space.chain) == 1);
fil_node_t *file= UT_LIST_GET_FIRST(space.chain);
/* The undo tablespace files are never closed. */
ut_ad(file->is_open());
sql_print_information("InnoDB: Starting to truncate %s", file->name);
for (auto &rseg : rseg_array)
if (rseg.space == &space)
{
/* Prevent a race with purge_sys_t::iterator::free_history_rseg() */
rseg.latch.rd_lock(SRW_LOCK_CALL);
/* Once set, this rseg will not be allocated to subsequent
transactions, but we will wait for existing active
transactions to finish. */
rseg.set_skip_allocation();
rseg.latch.rd_unlock();
}
}
inline fil_space_t *purge_sys_t::undo_truncate_try(uint32_t id, uint32_t size)
{
ut_ad(srv_is_undo_tablespace(id));
fil_space_t *space= fil_space_get(id);
if (space && space->get_size() > size)
{
truncate_undo_space.current= space;
trx_sys.undo_truncate_start(*space);
return space;
}
return nullptr;
}
fil_space_t *purge_sys_t::truncating_tablespace()
{
ut_ad(this == &purge_sys);
fil_space_t *space= truncate_undo_space.current;
if (space || srv_undo_tablespaces_active < 2 || !srv_undo_log_truncate)
return space;
const uint32_t size= uint32_t(srv_max_undo_log_size >> srv_page_size_shift);
for (uint32_t i= truncate_undo_space.last, j= i;; )
{
if (fil_space_t *s= undo_truncate_try(srv_undo_space_id_start + i, size))
return s;
++i;
i%= srv_undo_tablespaces_active;
if (i == j)
return nullptr;
}
}
#if defined __GNUC__ && __GNUC__ == 4 && !defined __clang__ #if defined __GNUC__ && __GNUC__ == 4 && !defined __clang__
# if defined __arm__ || defined __aarch64__ # if defined __arm__ || defined __aarch64__
/* Work around an internal compiler error in GCC 4.8.5 */ /* Work around an internal compiler error in GCC 4.8.5 */
@@ -590,55 +709,14 @@ TRANSACTIONAL_TARGET void trx_purge_truncate_history()
head.undo_no= 0; head.undo_no= 0;
} }
if (head.free_history() != DB_SUCCESS || srv_undo_tablespaces_active < 2) if (head.free_history() != DB_SUCCESS)
return; return;
while (srv_undo_log_truncate) while (fil_space_t *space= purge_sys.truncating_tablespace())
{ {
if (!purge_sys.truncate.current)
{
const ulint threshold=
ulint(srv_max_undo_log_size >> srv_page_size_shift);
for (uint32_t i= purge_sys.truncate.last
? purge_sys.truncate.last->id - srv_undo_space_id_start : 0,
j= i;; )
{
const uint32_t space_id= srv_undo_space_id_start + i;
ut_ad(srv_is_undo_tablespace(space_id));
fil_space_t *space= fil_space_get(space_id);
ut_a(UT_LIST_GET_LEN(space->chain) == 1);
if (space && space->get_size() > threshold)
{
purge_sys.truncate.current= space;
break;
}
++i;
i %= srv_undo_tablespaces_active;
if (i == j)
return;
}
}
fil_space_t &space= *purge_sys.truncate.current;
/* Undo tablespace always are a single file. */
fil_node_t *file= UT_LIST_GET_FIRST(space.chain);
/* The undo tablespace files are never closed. */
ut_ad(file->is_open());
DBUG_LOG("undo", "marking for truncate: " << file->name);
for (auto &rseg : trx_sys.rseg_array)
if (rseg.space == &space)
/* Once set, this rseg will not be allocated to subsequent
transactions, but we will wait for existing active
transactions to finish. */
rseg.set_skip_allocation();
for (auto &rseg : trx_sys.rseg_array) for (auto &rseg : trx_sys.rseg_array)
{ {
if (rseg.space != &space) if (rseg.space != space)
continue; continue;
rseg.latch.rd_lock(SRW_LOCK_CALL); rseg.latch.rd_lock(SRW_LOCK_CALL);
@@ -671,8 +749,9 @@ not_free:
rseg.latch.rd_unlock(); rseg.latch.rd_unlock();
} }
sql_print_information("InnoDB: Truncating %s", file->name); const char *file_name= UT_LIST_GET_FIRST(space->chain)->name;
trx_purge_cleanse_purge_queue(space); sql_print_information("InnoDB: Truncating %s", file_name);
trx_purge_cleanse_purge_queue(*space);
/* Lock all modified pages of the tablespace. /* Lock all modified pages of the tablespace.
@@ -689,12 +768,12 @@ not_free:
/* Adjust the tablespace metadata. */ /* Adjust the tablespace metadata. */
mysql_mutex_lock(&fil_system.mutex); mysql_mutex_lock(&fil_system.mutex);
if (space.crypt_data) if (space->crypt_data)
{ {
space.reacquire(); space->reacquire();
mysql_mutex_unlock(&fil_system.mutex); mysql_mutex_unlock(&fil_system.mutex);
fil_space_crypt_close_tablespace(&space); fil_space_crypt_close_tablespace(space);
space.release(); space->release();
} }
else else
mysql_mutex_unlock(&fil_system.mutex); mysql_mutex_unlock(&fil_system.mutex);
@@ -706,17 +785,17 @@ not_free:
mtr_t mtr; mtr_t mtr;
mtr.start(); mtr.start();
mtr.x_lock_space(&space); mtr.x_lock_space(space);
/* Associate the undo tablespace with mtr. /* Associate the undo tablespace with mtr.
During mtr::commit_shrink(), InnoDB can use the undo During mtr::commit_shrink(), InnoDB can use the undo
tablespace object to clear all freed ranges */ tablespace object to clear all freed ranges */
mtr.set_named_space(&space); mtr.set_named_space(space);
mtr.trim_pages(page_id_t(space.id, size)); mtr.trim_pages(page_id_t(space->id, size));
ut_a(fsp_header_init(&space, size, &mtr) == DB_SUCCESS); ut_a(fsp_header_init(space, size, &mtr) == DB_SUCCESS);
for (auto &rseg : trx_sys.rseg_array) for (auto &rseg : trx_sys.rseg_array)
{ {
if (rseg.space != &space) if (rseg.space != space)
continue; continue;
ut_ad(!rseg.is_referenced()); ut_ad(!rseg.is_referenced());
@@ -725,7 +804,7 @@ not_free:
possibly before this server had been started up. */ possibly before this server had been started up. */
dberr_t err; dberr_t err;
buf_block_t *rblock= trx_rseg_header_create(&space, buf_block_t *rblock= trx_rseg_header_create(space,
&rseg - trx_sys.rseg_array, &rseg - trx_sys.rseg_array,
trx_sys.get_max_trx_id(), trx_sys.get_max_trx_id(),
&mtr, &err); &mtr, &err);
@@ -738,7 +817,7 @@ not_free:
rseg.reinit(rblock->page.id().page_no()); rseg.reinit(rblock->page.id().page_no());
} }
mtr.commit_shrink(space, size); mtr.commit_shrink(*space, size);
/* No mutex; this is only updated by the purge coordinator. */ /* No mutex; this is only updated by the purge coordinator. */
export_vars.innodb_undo_truncations++; export_vars.innodb_undo_truncations++;
@@ -760,10 +839,10 @@ not_free:
log_buffer_flush_to_disk(); log_buffer_flush_to_disk();
DBUG_SUICIDE();); DBUG_SUICIDE(););
sql_print_information("InnoDB: Truncated %s", file->name); sql_print_information("InnoDB: Truncated %s", file_name);
purge_sys.truncate.last= purge_sys.truncate.current; ut_ad(space == purge_sys.truncate_undo_space.current);
ut_ad(&space == purge_sys.truncate.current); purge_sys.truncate_undo_space.current= nullptr;
purge_sys.truncate.current= nullptr; purge_sys.truncate_undo_space.last= space->id - srv_undo_space_id_start;
} }
} }

View File

@@ -907,15 +907,13 @@ trx_undo_truncate_start(
trx_undo_rec_t* last_rec; trx_undo_rec_t* last_rec;
mtr_t mtr; mtr_t mtr;
ut_ad(rseg->is_persistent());
if (!limit) { if (!limit) {
return DB_SUCCESS; return DB_SUCCESS;
} }
loop: loop:
mtr_start(&mtr); mtr.start();
if (!rseg->is_persistent()) {
mtr.set_log_mode(MTR_LOG_NO_REDO);
}
dberr_t err; dberr_t err;
const buf_block_t* undo_page; const buf_block_t* undo_page;

View File

@@ -403,10 +403,6 @@ int main(int argc __attribute__((unused)),
exit(1); exit(1);
} }
#ifdef HAVE_THR_SETCONCURRENCY
thr_setconcurrency(2);
#endif
if ((pagen= init_pagecache(&pagecache, PCACHE_SIZE, 0, 0, if ((pagen= init_pagecache(&pagecache, PCACHE_SIZE, 0, 0,
TEST_PAGE_SIZE, 0, 0)) == 0) TEST_PAGE_SIZE, 0, 0)) == 0)
{ {

View File

@@ -272,10 +272,6 @@ int main(int argc __attribute__((unused)),
exit(1); exit(1);
} }
#ifdef HAVE_THR_SETCONCURRENCY
thr_setconcurrency(2);
#endif
if ((pagen= init_pagecache(&pagecache, PCACHE_SIZE, 0, 0, if ((pagen= init_pagecache(&pagecache, PCACHE_SIZE, 0, 0,
TEST_PAGE_SIZE, 0, 0)) == 0) TEST_PAGE_SIZE, 0, 0)) == 0)
{ {

View File

@@ -268,10 +268,6 @@ int main(int argc __attribute__((unused)),
exit(1); exit(1);
} }
#ifdef HAVE_THR_SETCONCURRENCY
thr_setconcurrency(2);
#endif
if ((pagen= init_pagecache(&pagecache, PCACHE_SIZE, 0, 0, if ((pagen= init_pagecache(&pagecache, PCACHE_SIZE, 0, 0,
TEST_PAGE_SIZE, 0, 0)) == 0) TEST_PAGE_SIZE, 0, 0)) == 0)
{ {

View File

@@ -795,10 +795,6 @@ int main(int argc __attribute__((unused)),
exit(1); exit(1);
} }
#ifdef HAVE_THR_SETCONCURRENCY
thr_setconcurrency(2);
#endif
if ((pagen= init_pagecache(&pagecache, PCACHE_SIZE, 0, 0, if ((pagen= init_pagecache(&pagecache, PCACHE_SIZE, 0, 0,
TEST_PAGE_SIZE, 0, MYF(MY_WME))) == 0) TEST_PAGE_SIZE, 0, MYF(MY_WME))) == 0)
{ {

View File

@@ -331,10 +331,6 @@ int main(int argc __attribute__((unused)),
exit(1); exit(1);
} }
#ifdef HAVE_THR_SETCONCURRENCY
thr_setconcurrency(2);
#endif
if (ma_control_file_open(TRUE, TRUE, TRUE)) if (ma_control_file_open(TRUE, TRUE, TRUE))
{ {
fprintf(stderr, "Can't init control file (%d)\n", errno); fprintf(stderr, "Can't init control file (%d)\n", errno);

View File

@@ -3541,7 +3541,8 @@ CSphSEStats * sphinx_get_stats ( THD * thd, SHOW_VAR * out )
return 0; return 0;
} }
int sphinx_showfunc_total ( THD * thd, SHOW_VAR * out, char * ) static int sphinx_showfunc_total ( THD * thd, SHOW_VAR * out, void *,
system_status_var *, enum_var_type )
{ {
CSphSEStats * pStats = sphinx_get_stats ( thd, out ); CSphSEStats * pStats = sphinx_get_stats ( thd, out );
if ( pStats ) if ( pStats )
@@ -3552,7 +3553,8 @@ int sphinx_showfunc_total ( THD * thd, SHOW_VAR * out, char * )
return 0; return 0;
} }
int sphinx_showfunc_total_found ( THD * thd, SHOW_VAR * out, char * ) static int sphinx_showfunc_total_found ( THD * thd, SHOW_VAR * out, void *,
system_status_var *, enum_var_type )
{ {
CSphSEStats * pStats = sphinx_get_stats ( thd, out ); CSphSEStats * pStats = sphinx_get_stats ( thd, out );
if ( pStats ) if ( pStats )
@@ -3563,7 +3565,8 @@ int sphinx_showfunc_total_found ( THD * thd, SHOW_VAR * out, char * )
return 0; return 0;
} }
int sphinx_showfunc_time ( THD * thd, SHOW_VAR * out, char * ) static int sphinx_showfunc_time ( THD * thd, SHOW_VAR * out, void *,
system_status_var *, enum_var_type )
{ {
CSphSEStats * pStats = sphinx_get_stats ( thd, out ); CSphSEStats * pStats = sphinx_get_stats ( thd, out );
if ( pStats ) if ( pStats )
@@ -3574,7 +3577,8 @@ int sphinx_showfunc_time ( THD * thd, SHOW_VAR * out, char * )
return 0; return 0;
} }
int sphinx_showfunc_word_count ( THD * thd, SHOW_VAR * out, char * ) static int sphinx_showfunc_word_count ( THD * thd, SHOW_VAR * out, void *,
system_status_var *, enum_var_type )
{ {
CSphSEStats * pStats = sphinx_get_stats ( thd, out ); CSphSEStats * pStats = sphinx_get_stats ( thd, out );
if ( pStats ) if ( pStats )
@@ -3585,9 +3589,11 @@ int sphinx_showfunc_word_count ( THD * thd, SHOW_VAR * out, char * )
return 0; return 0;
} }
int sphinx_showfunc_words ( THD * thd, SHOW_VAR * out, char * sBuffer ) static int sphinx_showfunc_words ( THD * thd, SHOW_VAR * out, void * buf,
system_status_var *, enum_var_type )
{ {
#if MYSQL_VERSION_ID>50100 #if MYSQL_VERSION_ID>50100
char *sBuffer = static_cast<char*>(buf);
if ( sphinx_hton_ptr ) if ( sphinx_hton_ptr )
{ {
CSphTLS * pTls = (CSphTLS *) thd_get_ha_data ( thd, sphinx_hton_ptr ); CSphTLS * pTls = (CSphTLS *) thd_get_ha_data ( thd, sphinx_hton_ptr );
@@ -3642,7 +3648,8 @@ int sphinx_showfunc_words ( THD * thd, SHOW_VAR * out, char * sBuffer )
return 0; return 0;
} }
int sphinx_showfunc_error ( THD * thd, SHOW_VAR * out, char * ) static int sphinx_showfunc_error ( THD * thd, SHOW_VAR * out, void *,
system_status_var *, enum_var_type )
{ {
CSphSEStats * pStats = sphinx_get_stats ( thd, out ); CSphSEStats * pStats = sphinx_get_stats ( thd, out );
out->type = SHOW_CHAR; out->type = SHOW_CHAR;

View File

@@ -164,12 +164,6 @@ private:
bool sphinx_show_status ( THD * thd ); bool sphinx_show_status ( THD * thd );
#endif #endif
int sphinx_showfunc_total_found ( THD *, SHOW_VAR *, char * );
int sphinx_showfunc_total ( THD *, SHOW_VAR *, char * );
int sphinx_showfunc_time ( THD *, SHOW_VAR *, char * );
int sphinx_showfunc_word_count ( THD *, SHOW_VAR *, char * );
int sphinx_showfunc_words ( THD *, SHOW_VAR *, char * );
// //
// $Id: ha_sphinx.h 4818 2014-09-24 08:53:38Z tomat $ // $Id: ha_sphinx.h 4818 2014-09-24 08:53:38Z tomat $
// //

View File

@@ -8526,7 +8526,10 @@ int ha_spider::create(
if ( if (
thd->lex->create_info.or_replace() && thd->lex->create_info.or_replace() &&
(error_num = spider_delete_tables( (error_num = spider_delete_tables(
table_tables, tmp_share.table_name, &dummy)) table_tables, tmp_share.table_name, &dummy)) &&
/* In this context, no key found in mysql.spider_tables means
the Spider table does not exist */
error_num != HA_ERR_KEY_NOT_FOUND
) { ) {
goto error; goto error;
} }
@@ -8965,6 +8968,10 @@ int ha_spider::delete_table(
(error_num = spider_delete_tables( (error_num = spider_delete_tables(
table_tables, name, &old_link_count)) table_tables, name, &old_link_count))
) { ) {
/* In this context, no key found in mysql.spider_tables means
the Spider table does not exist */
if (error_num == HA_ERR_KEY_NOT_FOUND)
error_num= HA_ERR_NO_SUCH_TABLE;
goto error; goto error;
} }
spider_close_sys_table(current_thd, table_tables, spider_close_sys_table(current_thd, table_tables,

View File

@@ -6,6 +6,9 @@ for child2
for child3 for child3
set @old_spider_bgs_mode= @@spider_bgs_mode; set @old_spider_bgs_mode= @@spider_bgs_mode;
set session spider_bgs_mode=1; set session spider_bgs_mode=1;
set spider_same_server_link=1;
set @old_spider_same_server_link=@@global.spider_same_server_link;
set global spider_same_server_link=1;
CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table td (a int, PRIMARY KEY (a)); create table td (a int, PRIMARY KEY (a));
create table ts (a int, PRIMARY KEY (a)) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv_mdev_26151",TABLE "td", casual_read "3"'; create table ts (a int, PRIMARY KEY (a)) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv_mdev_26151",TABLE "td", casual_read "3"';
@@ -26,6 +29,7 @@ min(a)
drop table td, ts; drop table td, ts;
drop server srv_mdev_26151; drop server srv_mdev_26151;
set session spider_bgs_mode=@old_spider_bgs_mode; set session spider_bgs_mode=@old_spider_bgs_mode;
set global spider_same_server_link=@old_spider_same_server_link;
for master_1 for master_1
for child2 for child2
for child3 for child3

View File

@@ -5,6 +5,7 @@ for master_1
for child2 for child2
for child3 for child3
set global query_cache_type= on; set global query_cache_type= on;
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t2 (c int); create table t2 (c int);

View File

@@ -4,6 +4,7 @@
for master_1 for master_1
for child2 for child2
for child3 for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
# testing monitoring_* # testing monitoring_*

View File

@@ -4,8 +4,7 @@
for master_1 for master_1
for child2 for child2
for child3 for child3
set @old_spider_disable_group_by_handler=@@spider_disable_group_by_handler; set spider_same_server_link=1;
set spider_disable_group_by_handler=1;
CREATE SERVER s FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE SERVER s FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2); INSERT INTO t1 VALUES (1),(2);
@@ -17,7 +16,6 @@ a
2 2
DROP TABLE t2, t1_SPIDER, t1; DROP TABLE t2, t1_SPIDER, t1;
drop server s; drop server s;
set spider_disable_group_by_handler=@old_spider_disable_group_by_handler;
for master_1 for master_1
for child2 for child2
for child3 for child3

View File

@@ -0,0 +1,34 @@
for master_1
for child2
for child3
SET spider_same_server_link= on;
CREATE SERVER s FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t (a INT);
CREATE TABLE t1_spider (a INT) ENGINE=SPIDER COMMENT = "wrapper 'mysql', srv 's', table 't'";
CREATE TABLE t2_spider (a INT) ENGINE=SPIDER COMMENT = "wrapper 'mysql', srv 's', table 't'";
SELECT * FROM t1_spider, t2_spider;
a a
SELECT table_name, index_name, cardinality FROM INFORMATION_SCHEMA.STATISTICS WHERE table_name IN ('t1_spider','t2_spider');
table_name index_name cardinality
RENAME TABLE t1_spider TO t3_spider;
SELECT * FROM t3_spider;
a
DROP TABLE t3_spider, t2_spider, t;
drop server s;
CREATE TABLE t1 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",HOST "srv",TABLE "t"';
CREATE TABLE t2 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",HOST "srv",TABLE "t"';
CREATE TABLE t3 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",HOST "srv",TABLE "t"';
SHOW TABLE STATUS;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 SPIDER 10 NULL 0 0 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL Unable to connect to foreign data source: srv 0
t2 SPIDER 10 NULL 0 0 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL Unable to connect to foreign data source: srv 0
t3 SPIDER 10 NULL 0 0 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL Unable to connect to foreign data source: srv 0
Warnings:
Warning 1429 Unable to connect to foreign data source: srv
Warning 1429 Unable to connect to foreign data source: srv
Warning 1429 Unable to connect to foreign data source: srv
drop table t1, t2, t3;
for master_1
for child2
for child3

View File

@@ -4,6 +4,7 @@
for master_1 for master_1
for child2 for child2
for child3 for child3
set spider_same_server_link=1;
CREATE SERVER s FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE SERVER s FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);
CREATE TABLE t2 (b INT); CREATE TABLE t2 (b INT);

View File

@@ -4,6 +4,7 @@
for master_1 for master_1
for child2 for child2
for child3 for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t1 (c int); create table t1 (c int);

View File

@@ -4,6 +4,7 @@
for master_1 for master_1
for child2 for child2
for child3 for child3
set spider_same_server_link=1;
CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t (a INT); CREATE TABLE t (a INT);
INSERT INTO t VALUES (23),(48); INSERT INTO t VALUES (23),(48);

View File

@@ -4,6 +4,7 @@
for master_1 for master_1
for child2 for child2
for child3 for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t (a INT) ENGINE=Spider; CREATE TABLE t (a INT) ENGINE=Spider;

View File

@@ -4,6 +4,7 @@
for master_1 for master_1
for child2 for child2
for child3 for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t1 (c int); create table t1 (c int);

View File

@@ -0,0 +1,7 @@
install soname 'ha_spider';
DROP TABLE non_existing_table;
ERROR 42S02: Unknown table 'test.non_existing_table'
create or replace table non_existing_table (c int) engine=Spider;
drop table non_existing_table;
Warnings:
Warning 1620 Plugin is busy and will be uninstalled on shutdown

View File

@@ -4,6 +4,7 @@
for master_1 for master_1
for child2 for child2
for child3 for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2); INSERT INTO t1 VALUES (1),(2);

View File

@@ -4,6 +4,7 @@
for master_1 for master_1
for child2 for child2
for child3 for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t (c BLOB) ENGINE=InnoDB; CREATE TABLE t (c BLOB) ENGINE=InnoDB;
CREATE TABLE ts (c BLOB) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE "t"'; CREATE TABLE ts (c BLOB) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE "t"';

View File

@@ -5,6 +5,7 @@ for master_1
for child2 for child2
for child3 for child3
SET @old_spider_read_only_mode = @@session.spider_read_only_mode; SET @old_spider_read_only_mode = @@session.spider_read_only_mode;
set spider_same_server_link=1;
CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
set session spider_read_only_mode = default; set session spider_read_only_mode = default;
create table t2 (c int); create table t2 (c int);

View File

@@ -4,6 +4,7 @@
for master_1 for master_1
for child2 for child2
for child3 for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 ( a bigint(20) NOT NULL, b bigint(20) DEFAULT 0, PRIMARY KEY (a)); CREATE TABLE t1 ( a bigint(20) NOT NULL, b bigint(20) DEFAULT 0, PRIMARY KEY (a));
CREATE TABLE t2 ( a bigint(20) NOT NULL, b bigint(20) DEFAULT 0, PRIMARY KEY (a)) ENGINE=SPIDER COMMENT='srv "srv", WRAPPER "mysql", TABLE "t1"'; CREATE TABLE t2 ( a bigint(20) NOT NULL, b bigint(20) DEFAULT 0, PRIMARY KEY (a)) ENGINE=SPIDER COMMENT='srv "srv", WRAPPER "mysql", TABLE "t1"';

View File

@@ -1,6 +1,7 @@
for master_1 for master_1
for child2 for child2
for child3 for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
set session spider_delete_all_rows_type=0; set session spider_delete_all_rows_type=0;

View File

@@ -4,6 +4,7 @@
for master_1 for master_1
for child2 for child2
for child3 for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t2 (c varchar(16)); create table t2 (c varchar(16));

View File

@@ -0,0 +1,25 @@
for master_1
for child2
for child3
set spider_same_server_link=on;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t2 (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
);
create table t1 ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=SPIDER DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"'
drop table t1, t2;
drop server srv;
for master_1
for child2
for child3

View File

@@ -4,6 +4,9 @@ for child3
MDEV-6268 SPIDER table with no COMMENT clause causes queries to wait forever MDEV-6268 SPIDER table with no COMMENT clause causes queries to wait forever
set spider_same_server_link=1;
set @old_spider_same_server_link=@@global.spider_same_server_link;
set global spider_same_server_link=1;
CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t2 (c int); create table t2 (c int);
create table t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv_self_reference_multi",TABLE "t2"'; create table t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv_self_reference_multi",TABLE "t2"';
@@ -17,6 +20,7 @@ select * from t2;
ERROR HY000: An infinite loop is detected when opening table test.t0 ERROR HY000: An infinite loop is detected when opening table test.t0
drop table t0, t1, t2; drop table t0, t1, t2;
drop server srv_self_reference_multi; drop server srv_self_reference_multi;
set global spider_same_server_link=@old_spider_same_server_link;
for master_1 for master_1
for child2 for child2
for child3 for child3

View File

@@ -0,0 +1,8 @@
#
# MDEV-32559 Move alter table statements in spider init queries to be executed in the signal_ddl_recovery_done callback
#
select * from mysql.plugin;
name dl
#
# end of test signal_ddl_fail
#

View File

@@ -4,6 +4,7 @@
for master_1 for master_1
for child2 for child2
for child3 for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t1 (c int); create table t1 (c int);
create table t2 (d int); create table t2 (d int);

View File

@@ -4,6 +4,7 @@
for master_1 for master_1
for child2 for child2
for child3 for child3
set spider_same_server_link=1;
CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t1 (c1 int); create table t1 (c1 int);
create table t2 (c2 int); create table t2 (c2 int);

View File

@@ -14,6 +14,10 @@
--let $srv=srv_mdev_26151 --let $srv=srv_mdev_26151
set @old_spider_bgs_mode= @@spider_bgs_mode; set @old_spider_bgs_mode= @@spider_bgs_mode;
set session spider_bgs_mode=1; set session spider_bgs_mode=1;
set spider_same_server_link=1;
set @old_spider_same_server_link=@@global.spider_same_server_link;
set global spider_same_server_link=1;
evalp CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); evalp CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
# casual_read != 0 && casual_read != 1 # casual_read != 0 && casual_read != 1
@@ -42,6 +46,7 @@ drop table td, ts;
eval drop server $srv; eval drop server $srv;
set session spider_bgs_mode=@old_spider_bgs_mode; set session spider_bgs_mode=@old_spider_bgs_mode;
set global spider_same_server_link=@old_spider_same_server_link;
--disable_query_log --disable_query_log
--disable_result_log --disable_result_log

View File

@@ -12,6 +12,7 @@
#set @@global.debug_dbug="d:t:i:o,mysqld.trace"; #set @@global.debug_dbug="d:t:i:o,mysqld.trace";
set global query_cache_type= on; set global query_cache_type= on;
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t2 (c int); create table t2 (c int);

View File

@@ -9,6 +9,7 @@
# This test covers some table params under consideration for inclusion # This test covers some table params under consideration for inclusion
# in the engine-defined options to be implemented in MDEV-28856. # in the engine-defined options to be implemented in MDEV-28856.
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');

View File

@@ -12,9 +12,7 @@ if (`select not(count(*)) from information_schema.system_variables where variabl
--source ../../t/test_init.inc --source ../../t/test_init.inc
--enable_result_log --enable_result_log
--enable_query_log --enable_query_log
# FIXME: this is a workaround. set spider_same_server_link=1;
set @old_spider_disable_group_by_handler=@@spider_disable_group_by_handler;
set spider_disable_group_by_handler=1;
evalp CREATE SERVER s FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); evalp CREATE SERVER s FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);
@@ -27,7 +25,6 @@ SELECT * FROM t2;
# Cleanup # Cleanup
DROP TABLE t2, t1_SPIDER, t1; DROP TABLE t2, t1_SPIDER, t1;
drop server s; drop server s;
set spider_disable_group_by_handler=@old_spider_disable_group_by_handler;
--disable_query_log --disable_query_log
--disable_result_log --disable_result_log

View File

@@ -0,0 +1,32 @@
--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
SET spider_same_server_link= on;
evalp CREATE SERVER s FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t (a INT);
CREATE TABLE t1_spider (a INT) ENGINE=SPIDER COMMENT = "wrapper 'mysql', srv 's', table 't'";
CREATE TABLE t2_spider (a INT) ENGINE=SPIDER COMMENT = "wrapper 'mysql', srv 's', table 't'";
SELECT * FROM t1_spider, t2_spider;
SELECT table_name, index_name, cardinality FROM INFORMATION_SCHEMA.STATISTICS WHERE table_name IN ('t1_spider','t2_spider');
RENAME TABLE t1_spider TO t3_spider;
SELECT * FROM t3_spider;
DROP TABLE t3_spider, t2_spider, t;
drop server s;
# case by roel
CREATE TABLE t1 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",HOST "srv",TABLE "t"';
CREATE TABLE t2 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",HOST "srv",TABLE "t"';
CREATE TABLE t3 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",HOST "srv",TABLE "t"';
SHOW TABLE STATUS;
drop table t1, t2, t3;
--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc
--enable_result_log
--enable_query_log

View File

@@ -6,6 +6,7 @@
--source ../../t/test_init.inc --source ../../t/test_init.inc
--enable_result_log --enable_result_log
--enable_query_log --enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER s FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); evalp CREATE SERVER s FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);

View File

@@ -8,6 +8,7 @@
--enable_result_log --enable_result_log
--enable_query_log --enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');

View File

@@ -8,6 +8,7 @@
--enable_result_log --enable_result_log
--enable_query_log --enable_query_log
set spider_same_server_link=1;
--let $srv=srv_mdev_29502 --let $srv=srv_mdev_29502
evalp CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); evalp CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');

View File

@@ -7,6 +7,7 @@
--enable_result_log --enable_result_log
--enable_query_log --enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');

View File

@@ -7,6 +7,7 @@
--enable_result_log --enable_result_log
--enable_query_log --enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');

View File

@@ -0,0 +1,8 @@
install soname 'ha_spider';
--error ER_BAD_TABLE_ERROR
DROP TABLE non_existing_table;
# Test that create or replace a non existing spider table work
create or replace table non_existing_table (c int) engine=Spider;
drop table non_existing_table;
--disable_query_log
--source ../../include/clean_up_spider.inc

View File

@@ -6,6 +6,7 @@
--source ../../t/test_init.inc --source ../../t/test_init.inc
--enable_result_log --enable_result_log
--enable_query_log --enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);

View File

@@ -9,6 +9,7 @@
--enable_result_log --enable_result_log
--enable_query_log --enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t (c BLOB) ENGINE=InnoDB; CREATE TABLE t (c BLOB) ENGINE=InnoDB;
CREATE TABLE ts (c BLOB) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE "t"'; CREATE TABLE ts (c BLOB) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE "t"';

View File

@@ -10,6 +10,7 @@
--let $srv=srv_mdev_31524 --let $srv=srv_mdev_31524
SET @old_spider_read_only_mode = @@session.spider_read_only_mode; SET @old_spider_read_only_mode = @@session.spider_read_only_mode;
set spider_same_server_link=1;
evalp CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); evalp CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
# when the user does not set var nor the table option, the default # when the user does not set var nor the table option, the default

View File

@@ -6,6 +6,7 @@
--source ../../t/test_init.inc --source ../../t/test_init.inc
--enable_result_log --enable_result_log
--enable_query_log --enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE t1 ( a bigint(20) NOT NULL, b bigint(20) DEFAULT 0, PRIMARY KEY (a)); CREATE TABLE t1 ( a bigint(20) NOT NULL, b bigint(20) DEFAULT 0, PRIMARY KEY (a));

View File

@@ -4,6 +4,7 @@
--enable_result_log --enable_result_log
--enable_query_log --enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');

View File

@@ -6,6 +6,7 @@
--source ../../t/test_init.inc --source ../../t/test_init.inc
--enable_result_log --enable_result_log
--enable_query_log --enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');

View File

@@ -0,0 +1,24 @@
--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
set spider_same_server_link=on;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t2 (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
);
create table t1 ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
show create table t1;
drop table t1, t2;
drop server srv;
--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc
--enable_result_log
--enable_query_log

View File

@@ -8,6 +8,9 @@
--echo MDEV-6268 SPIDER table with no COMMENT clause causes queries to wait forever --echo MDEV-6268 SPIDER table with no COMMENT clause causes queries to wait forever
--echo --echo
set spider_same_server_link=1;
set @old_spider_same_server_link=@@global.spider_same_server_link;
set global spider_same_server_link=1;
--let $srv=srv_self_reference_multi --let $srv=srv_self_reference_multi
evalp CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); evalp CREATE SERVER $srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t2 (c int); create table t2 (c int);
@@ -22,6 +25,7 @@ select * from t1;
select * from t2; select * from t2;
drop table t0, t1, t2; drop table t0, t1, t2;
eval drop server $srv; eval drop server $srv;
set global spider_same_server_link=@old_spider_same_server_link;
--disable_query_log --disable_query_log
--disable_result_log --disable_result_log

View File

@@ -0,0 +1,2 @@
--plugin-load-add=ha_spider
--debug-dbug=d,fail_spider_ddl_recovery_done

View File

@@ -0,0 +1,10 @@
--source include/have_debug.inc
--echo #
--echo # MDEV-32559 Move alter table statements in spider init queries to be executed in the signal_ddl_recovery_done callback
--echo #
# This test tests that failure in ddl_recovery callback causes the
# plugin to be deinitialized.
select * from mysql.plugin;
--echo #
--echo # end of test signal_ddl_fail
--echo #

View File

@@ -8,6 +8,7 @@
--enable_result_log --enable_result_log
--enable_query_log --enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t1 (c int); create table t1 (c int);
create table t2 (d int); create table t2 (d int);

View File

@@ -6,6 +6,7 @@
--source ../../t/test_init.inc --source ../../t/test_init.inc
--enable_result_log --enable_result_log
--enable_query_log --enable_query_log
set spider_same_server_link=1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); evalp CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table t1 (c1 int); create table t1 (c1 int);
create table t2 (c2 int); create table t2 (c2 int);

Some files were not shown because too many files have changed in this diff Show More