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

Merge branch '10.5' into 10.6

This commit is contained in:
Oleksandr Byelkin
2024-10-29 14:20:03 +01:00
128 changed files with 1857 additions and 843 deletions

View File

@@ -3883,9 +3883,9 @@ void do_move_file(struct st_command *command)
is_sub_path(ds_to_file.str, to_plen, vardir)) ||
(is_sub_path(ds_from_file.str, from_plen, tmpdir) &&
is_sub_path(ds_to_file.str, to_plen, tmpdir)))) {
report_or_die("Paths '%s' and '%s' are not both under MYSQLTEST_VARDIR '%s'"
"or both under MYSQL_TMP_DIR '%s'",
ds_from_file, ds_to_file, vardir, tmpdir);
report_or_die("Paths '%s' and '%s' are not both under "
"MYSQLTEST_VARDIR '%s' or both under MYSQL_TMP_DIR '%s'",
ds_from_file.str, ds_to_file.str, vardir, tmpdir);
DBUG_VOID_RETURN;
}

View File

@@ -229,7 +229,8 @@ IF(WITH_WSREP)
SETA(CPACK_RPM_server_PACKAGE_REQUIRES
"galera-4" "rsync" "grep" "gawk" "iproute"
"coreutils" "findutils" "tar")
SETA(CPACK_RPM_server_PACKAGE_RECOMMENDS "lsof")
SETA(CPACK_RPM_server_PACKAGE_RECOMMENDS "lsof" "socat")
SETA(CPACK_RPM_test_PACKAGE_REQUIRES "socat")
ENDIF()
SET(CPACK_RPM_server_PRE_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-prein.sh)

View File

@@ -20,9 +20,6 @@
# #Legacy option, maybe not needed anymore , taken as is from autotools build
# ADD_DEFINITIONS(-DNET_RETRY_COUNT=1000000)
# The below was used for really old versions of FreeBSD, roughly: before 5.1.9
# ADD_DEFINITIONS(-DHAVE_BROKEN_REALPATH)
# Find libexecinfo (library that contains backtrace_symbols etc)
SET(EXECINFO_ROOT /usr/local CACHE INTERNAL "Where to find execinfo library and header")
INCLUDE_DIRECTORIES(${EXECINFO_ROOT}/include)

View File

@@ -196,6 +196,7 @@
#cmakedefine HAVE_PTHREAD_ATTR_GETSTACKSIZE 1
#cmakedefine HAVE_PTHREAD_ATTR_SETSCOPE 1
#cmakedefine HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
#cmakedefine HAVE_PTHREAD_GETATTR_NP 1
#cmakedefine HAVE_PTHREAD_CONDATTR_CREATE 1
#cmakedefine HAVE_PTHREAD_GETAFFINITY_NP 1
#cmakedefine HAVE_PTHREAD_KEY_DELETE 1

View File

@@ -379,6 +379,7 @@ CHECK_FUNCTION_EXISTS (pthread_attr_getguardsize HAVE_PTHREAD_ATTR_GETGUARDSIZE)
CHECK_FUNCTION_EXISTS (pthread_attr_setstacksize HAVE_PTHREAD_ATTR_SETSTACKSIZE)
CHECK_FUNCTION_EXISTS (pthread_condattr_create HAVE_PTHREAD_CONDATTR_CREATE)
CHECK_FUNCTION_EXISTS (pthread_getaffinity_np HAVE_PTHREAD_GETAFFINITY_NP)
CHECK_FUNCTION_EXISTS (pthread_getattr_np HAVE_PTHREAD_GETATTR_NP)
CHECK_FUNCTION_EXISTS (pthread_key_delete HAVE_PTHREAD_KEY_DELETE)
CHECK_FUNCTION_EXISTS (pthread_rwlock_rdlock HAVE_PTHREAD_RWLOCK_RDLOCK)
CHECK_FUNCTION_EXISTS (pthread_sigmask HAVE_PTHREAD_SIGMASK)

View File

@@ -6867,7 +6867,6 @@ void handle_options(int argc, char **argv, char ***argv_server,
}
static int main_low(char** argv);
static int get_exepath(char *buf, size_t size, const char *argv0);
/* ================= main =================== */
int main(int argc, char **argv)
@@ -6878,8 +6877,8 @@ int main(int argc, char **argv)
my_getopt_prefix_matching= 0;
if (get_exepath(mariabackup_exe,FN_REFLEN, argv[0]))
strncpy(mariabackup_exe,argv[0], FN_REFLEN-1);
if (my_get_exepath(mariabackup_exe, FN_REFLEN, argv[0]))
strncpy(mariabackup_exe, argv[0], FN_REFLEN-1);
if (argc > 1 )
@@ -7176,32 +7175,6 @@ static int main_low(char** argv)
}
static int get_exepath(char *buf, size_t size, const char *argv0)
{
#ifdef _WIN32
DWORD ret = GetModuleFileNameA(NULL, buf, (DWORD)size);
if (ret > 0)
return 0;
#elif defined(__linux__)
ssize_t ret = readlink("/proc/self/exe", buf, size-1);
if(ret > 0)
return 0;
#elif defined(__APPLE__)
size_t ret = proc_pidpath(getpid(), buf, static_cast<uint32_t>(size));
if (ret > 0) {
buf[ret] = 0;
return 0;
}
#elif defined(__FreeBSD__)
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
if (sysctl(mib, 4, buf, &size, NULL, 0) == 0) {
return 0;
}
#endif
return my_realpath(buf, argv0, 0);
}
#if defined (__SANITIZE_ADDRESS__) && defined (__linux__)
/* Avoid LeakSanitizer's false positives. */

View File

@@ -285,12 +285,19 @@ static inline void safe_strcpy(char *dst, size_t dst_size, const char *src)
static inline int safe_strcpy_truncated(char *dst, size_t dst_size,
const char *src)
{
DBUG_ASSERT(dst_size > 0);
strncpy(dst, src, dst_size);
if (dst[dst_size - 1])
DBUG_ASSERT(dst_size > 0);
if (dst_size == 0)
return 1;
/*
We do not want to use strncpy() as we do not want to rely on
strncpy() filling the unused dst with 0.
We cannot use strmake() here as it in debug mode fills the buffers
with 'Z'.
*/
if (strnmov(dst, src, dst_size) == dst+dst_size)
{
dst[dst_size - 1]= 0;
dst[dst_size-1]= 0;
return 1;
}
return 0;
@@ -306,7 +313,7 @@ static inline int safe_strcpy_truncated(char *dst, size_t dst_size,
static inline int safe_strcat(char *dst, size_t dst_size, const char *src)
{
size_t init_len= strlen(dst);
if (init_len > dst_size)
if (init_len >= dst_size)
return 1;
return safe_strcpy_truncated(dst + init_len, dst_size - init_len, src);
}

View File

@@ -823,7 +823,6 @@ typedef long long my_ptrdiff_t;
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A), sizeof(double)))
#define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size)
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B))
#define PREV_BITS(type,A) ((type) (((type) 1 << (A)) -1))
/*
Custom version of standard offsetof() macro which can be used to get

View File

@@ -17,6 +17,65 @@
#ifndef _my_stack_alloc_h
#define _my_stack_alloc_h
#ifdef _MSC_VER
#include <intrin.h> // For MSVC-specific intrinsics
#else
#include <sys/resource.h>
#endif
/*
Get the address of the current stack.
This will fallback to using an estimate for the stack pointer
in the cases where either the compiler or the architecture is
not supported.
*/
static inline void *my_get_stack_pointer(void *default_stack)
{
void *stack_ptr= NULL;
#if defined(__GNUC__) || defined(__clang__) /* GCC and Clang compilers */
#if defined(__i386__) /* Intel x86 (32-bit) */
__asm__ volatile ("movl %%esp, %0" : "=r" (stack_ptr));
#elif defined(__x86_64__) /* Intel x86-64 (64-bit) */
__asm__ volatile ("movq %%rsp, %0" : "=r" (stack_ptr));
#elif defined(__powerpc__) /* PowerPC (32-bit) */
__asm__ volatile ("mr %0, 1" : "=r" (stack_ptr)); /* GPR1 is the stack pointer */
#elif defined(__ppc64__) /* PowerPC (64-bit) */
__asm__ volatile ("mr %0, 1" : "=r" (stack_ptr));
#elif defined(__arm__) /* ARM 32-bit */
__asm__ volatile ("mov %0, sp" : "=r" (stack_ptr));
#elif defined(__aarch64__) /* ARM 64-bit */
__asm__ volatile ("mov %0, sp" : "=r" (stack_ptr));
#elif defined(__sparc__) /* SPARC 32-bit */
__asm__ volatile ("mov %%sp, %0" : "=r" (stack_ptr));
#elif defined(__sparc64__) /* SPARC 64-bit */
__asm__ volatile ("mov %%sp, %0" : "=r" (stack_ptr));
#elif defined(__s390x__)
stack_ptr= __builtin_frame_address(0);
#else
/* Generic fallback for unsupported architectures in GCC/Clang */
stack_ptr= default_stack ? default_stack : (void*) &stack_ptr;
#endif
#elif defined(_MSC_VER) /* MSVC compiler (Intel only) */
#if defined(_M_IX86) /* Intel x86 (32-bit) */
__asm { mov stack_ptr, esp }
#elif defined(_M_X64) /* Intel x86-64 (64-bit) */
/* rsp cant be accessed directly in MSVC x64 */
stack_ptr= _AddressOfReturnAddress();
#else
/* Generic fallback for unsupported architectures in MSVC */
stack_ptr= default_stack ? default_stack : (void*) &stack_ptr;
#endif
#else
/* Generic fallback for unsupported compilers */
stack_ptr= default_stack ? default_stack : (void*) &stack_ptr;
#endif
return stack_ptr;
}
/*
Do allocation through alloca if there is enough stack available.
If not, use my_malloc() instead.
@@ -42,7 +101,7 @@
/* Allocate small blocks as long as there is this much left */
#define STACK_ALLOC_SMALL_BLOCK 1024*32
/* Allocate small blocks as long as there is this much left */
/* Allocate small blocks as long as the block size is not bigger than */
#define STACK_ALLOC_SMALL_BLOCK_SIZE 4096
/*
@@ -56,11 +115,11 @@
do \
{ \
size_t alloc_size= (size); \
size_t stack_left= available_stack_size(&alloc_size, (stack_end)); \
if (stack_left > alloc_size && \
(STACK_ALLOC_BIG_BLOCK < stack_left - alloc_size || \
((STACK_ALLOC_SMALL_BLOCK < stack_left - alloc_size) && \
(STACK_ALLOC_SMALL_BLOCK_SIZE <= alloc_size)))) \
void *stack= my_get_stack_pointer(0); \
size_t stack_left= available_stack_size(stack, (stack_end)); \
if (stack_left > alloc_size + STACK_ALLOC_SMALL_BLOCK && \
(stack_left > alloc_size + STACK_ALLOC_BIG_BLOCK || \
(STACK_ALLOC_SMALL_BLOCK_SIZE >= alloc_size))) \
{ \
(must_be_freed)= 0; \
(res)= alloca(size); \
@@ -90,3 +149,16 @@ static inline void stack_alloc_free(void *res, my_bool must_be_freed)
my_free(res);
}
#endif /* _my_stack_alloc_h */
/* Get start and end of stack */
/*
This is used in the case when we not know the exact stack start
and have to estimate stack start with get_stack_pointer()
*/
#define MY_STACK_SAFE_MARGIN 8192
extern void my_get_stack_bounds(void **stack_start, void **stack_end,
void *fallback_stack_start,
size_t fallback_stack_size);

View File

@@ -654,6 +654,8 @@ extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags);
extern my_off_t my_ftell(FILE *stream,myf MyFlags);
extern void (*my_sleep_for_space)(unsigned int seconds);
extern int my_get_exepath(char *buf, size_t size, const char *argv0);
/* implemented in my_memmem.c */
extern void *my_memmem(const void *haystack, size_t haystacklen,
const void *needle, size_t needlelen);

View File

@@ -114,6 +114,10 @@ sub create_process {
lock($win32_spawn_lock);
# STDOUT/STDERR are temporarily reassigned, avoid prevent
# output from another thread
lock($mtr_report::flush_lock);
#printf STDERR "stdin %d, stdout %d, stderr %d\n",
# fileno STDIN, fileno STDOUT, fileno STDERR;

View File

@@ -88,7 +88,7 @@ sub flush_out {
}
use if $^O eq "MSWin32", "threads::shared";
my $flush_lock :shared;
our $flush_lock :shared;
# Print to stdout
sub print_out {

View File

@@ -461,11 +461,13 @@ Connection_errors_max_connections 0
Connection_errors_peer_address 0
Connection_errors_select 0
Connection_errors_tcpwrap 0
show global status like 'Threads_connected';
Variable_name Value
Threads_connected 1
set @max_con.save= @@max_connections;
set global max_connections= 10;
# ERROR 1040
# ERROR 1040
connection default;
show global status like 'Connection_errors%';
Variable_name Value
Connection_errors_accept 0

View File

@@ -517,6 +517,7 @@ SET GLOBAL connect_timeout= @save_connect_timeout;
flush status;
show global status like 'Connection_errors%';
show global status like 'Threads_connected';
set @max_con.save= @@max_connections;
set global max_connections= 10;
@@ -534,9 +535,25 @@ while ($n)
--dec $n
}
connection default;
let $n= 10;
let $c= 12;
while ($n)
{
disconnect con$c;
--dec $n
--dec $c
}
# Wait until all connections has terminated to ensure
# that Connection_errors is correct
let $status_var=Threads_connected;
let $status_var_value= 1;
--source include/wait_for_status_var.inc
--enable_result_log
--enable_query_log
--connection default
show global status like 'Connection_errors%';
set global max_connections= @max_con.save;

File diff suppressed because it is too large Load Diff

View File

@@ -19053,4 +19053,31 @@ EXPLAIN
}
}
drop table t1, t2;
#
# MDEV-35276: Assertion failure in find_producing_item upon a query
# from a view
#
# Note: for all followng queries with DEFAULT(f) hishdown is
# prohibited
CREATE VIEW v AS select 0 AS f;
SELECT * FROM v WHERE f = DEFAULT(f);
f
0
CREATE TABLE t1 (c int DEFAULT 0);
insert into t1 values (0), (1);
SELECT * FROM v,t1 WHERE f = DEFAULT(c);
f c
0 0
0 1
ALTER TABLE t1 ALTER c SET DEFAULT 1;
SELECT * FROM v,t1 WHERE f = DEFAULT(c);
f c
drop table t1;
create table t1 (a int, c int DEFAULT a);
insert into t1 values (0, -1), (1, -2);
SELECT * FROM v,t1 WHERE f = DEFAULT(c);
f a c
0 0 -1
DROP VIEW v;
DROP TABLE t1;
# End of 10.5 tests

View File

@@ -4189,4 +4189,34 @@ execute stmt;
drop table t1, t2;
--echo #
--echo # MDEV-35276: Assertion failure in find_producing_item upon a query
--echo # from a view
--echo #
--echo # Note: for all followng queries with DEFAULT(f) hishdown is
--echo # prohibited
CREATE VIEW v AS select 0 AS f;
SELECT * FROM v WHERE f = DEFAULT(f);
CREATE TABLE t1 (c int DEFAULT 0);
insert into t1 values (0), (1);
SELECT * FROM v,t1 WHERE f = DEFAULT(c);
ALTER TABLE t1 ALTER c SET DEFAULT 1;
SELECT * FROM v,t1 WHERE f = DEFAULT(c);
drop table t1;
create table t1 (a int, c int DEFAULT a);
insert into t1 values (0, -1), (1, -2);
SELECT * FROM v,t1 WHERE f = DEFAULT(c);
DROP VIEW v;
DROP TABLE t1;
--echo # End of 10.5 tests

View File

@@ -45,7 +45,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
INSERT INTO t1 values (1,'abba');
CREATE TABLE t2 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=Memory;
ERROR 42000: Unknown storage engine 'MEMORY'
ERROR HY000: The MariaDB server is running with the NO_ENGINE_SUBSTITUTION option so it cannot execute this statement
SET SESSION sql_mode='';
SET SESSION enforce_storage_engine=MyISAM;
select @@session.enforce_storage_engine;

View File

@@ -26,7 +26,7 @@ CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=MyISA
SHOW CREATE TABLE t1;
INSERT INTO t1 values (1,'abba');
--error 1286
--error ER_OPTION_PREVENTS_STATEMENT
CREATE TABLE t2 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=Memory;
SET SESSION sql_mode='';

View File

@@ -11,5 +11,5 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
set session sql_mode='no_engine_substitution';
create table t2 (c1 int primary key auto_increment, c2 varchar(10)) engine=memory;
ERROR 42000: Unknown storage engine 'MEMORY'
ERROR HY000: The MariaDB server is running with the NO_ENGINE_SUBSTITUTION option so it cannot execute this statement
drop table t1;

View File

@@ -2,6 +2,6 @@ SET SQL_MODE="";
create table t1 (c1 int primary key auto_increment, c2 varchar(10)) engine=memory;
show create table t1;
set session sql_mode='no_engine_substitution';
--error 1286
--error ER_OPTION_PREVENTS_STATEMENT
create table t2 (c1 int primary key auto_increment, c2 varchar(10)) engine=memory;
drop table t1;

View File

@@ -174,7 +174,7 @@ drop user 'O\'Brien'@'localhost';
#
CREATE USER 'test-user';
CREATE ROLE `r``o'l"e`;
select user from mysql.user where is_role='Y';
select user as User from mysql.user where is_role='Y';
User
r`o'l"e
GRANT `r``o'l"e` TO 'test-user';
@@ -346,7 +346,7 @@ ERROR HY000: Password hash should be a 41-digit hexadecimal number
set password for u7@h = old_password('pwd');
create user u8@h identified with 'mysql_old_password';
set password for u8@h = '78a302dd267f6044';
select user,host,plugin,authentication_string from mysql.user where host='h';
select user as User,host as Host,plugin,authentication_string from mysql.user where host='h';
User Host plugin authentication_string
u1 h mysql_native_password *975B2CD4FF9AE554FE8AD33168FBFC326D2021DD
u2 h mysql_native_password *975B2CD4FF9AE554FE8AD33168FBFC326D2021DD
@@ -392,7 +392,7 @@ grant select on *.* to u5@h;
grant select on *.* to u6@h;
grant select on *.* to u7@h;
grant select on *.* to u8@h;
select user,select_priv,plugin,authentication_string from mysql.user where user like 'u_';
select user as User,select_priv as Select_priv,plugin,authentication_string from mysql.user where user like 'u_';
User Select_priv plugin authentication_string
u1 Y mysql_native_password bad
u2 Y mysql_native_password *975B2CD4FF9AE554FE8AD33168FBFC326D2021DD

View File

@@ -131,7 +131,7 @@ drop user 'O\'Brien'@'localhost';
CREATE USER 'test-user';
CREATE ROLE `r``o'l"e`;
select user from mysql.user where is_role='Y';
select user as User from mysql.user where is_role='Y';
GRANT `r``o'l"e` TO 'test-user';
SET DEFAULT ROLE `r``o'l"e` FOR 'test-user';
# it is expected that quotes won't be shown correctly
@@ -310,7 +310,7 @@ set password for u7@h = old_password('pwd');
create user u8@h identified with 'mysql_old_password';
eval set password for u8@h = '$p';
sorted_result;
select user,host,plugin,authentication_string from mysql.user where host='h';
select user as User,host as Host,plugin,authentication_string from mysql.user where host='h';
# test with invalid entries
update mysql.global_priv set priv=json_set(priv, '$.authentication_string', 'bad') where user='u1';
update mysql.global_priv set priv=json_set(priv, '$.authentication_string', 'bad') where user='u5';
@@ -332,7 +332,7 @@ grant select on *.* to u5@h;
grant select on *.* to u6@h;
grant select on *.* to u7@h;
grant select on *.* to u8@h;
select user,select_priv,plugin,authentication_string from mysql.user where user like 'u_';
select user as User,select_priv as Select_priv,plugin,authentication_string from mysql.user where user like 'u_';
# but they still can be dropped
drop user u1@h, u2@h, u3@h, u4@h, u5@h, u6@h, u7@h, u8@h;

View File

@@ -2987,3 +2987,15 @@ drop table t20, t21, t22;
#
# End of 10.3 tests
#
#
# MDEV-29351 SIGSEGV when doing forward reference of item in select list
#
CREATE TABLE t1 (a INT);
UPDATE t1 SET c=1 ORDER BY (SELECT c);
ERROR 42S22: Reference 'c' not supported (forward reference in item list)
UPDATE t1 SET c=1 ORDER BY (SELECT c);
ERROR 42S22: Reference 'c' not supported (forward reference in item list)
DROP TABLE t1;
#
# End of 10.5 tests
#

View File

@@ -2140,3 +2140,18 @@ drop table t20, t21, t22;
--echo #
--echo # End of 10.3 tests
--echo #
--echo #
--echo # MDEV-29351 SIGSEGV when doing forward reference of item in select list
--echo #
CREATE TABLE t1 (a INT);
--error ER_ILLEGAL_REFERENCE
UPDATE t1 SET c=1 ORDER BY (SELECT c);
--error ER_ILLEGAL_REFERENCE
UPDATE t1 SET c=1 ORDER BY (SELECT c);
DROP TABLE t1;
--echo #
--echo # End of 10.5 tests
--echo #

View File

@@ -35,3 +35,25 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE a ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE g ref groups_dt groups_dt 70 const,test.a.type 13 Using index condition
drop table t0,t1,t2,t3;
#
# MDEV-35253: xa_prepare_unlock_unmodified fails: shift exponent 32 is too large
#
set @create=
concat("create table t1(",
(select group_concat(concat("col",seq, " int")) from seq_1_to_32),
",\n index idx1(",
(select group_concat(concat("col",seq)) from seq_1_to_32),
")\n)"
);
$create_tbl;
insert into t1() values (),(),();
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
# Must not produce a "shift exponent 32 is too large" runtime ubsan error
explain select * from t1 where col1=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref idx1 idx1 5 const 1 Using index
drop table t1;
End of 10.5 tests

View File

@@ -45,3 +45,27 @@ SELECT STRAIGHT_JOIN g.id FROM t2 a, t3 g USE INDEX(groups_dt)
WHERE g.domain = 'queue' AND g.type = a.type;
drop table t0,t1,t2,t3;
--echo #
--echo # MDEV-35253: xa_prepare_unlock_unmodified fails: shift exponent 32 is too large
--echo #
--source include/have_sequence.inc
set @create=
concat("create table t1(",
(select group_concat(concat("col",seq, " int")) from seq_1_to_32),
",\n index idx1(",
(select group_concat(concat("col",seq)) from seq_1_to_32),
")\n)"
);
let $create_tbl=`select @create`;
evalp $create_tbl;
insert into t1() values (),(),();
analyze table t1;
--echo # Must not produce a "shift exponent 32 is too large" runtime ubsan error
explain select * from t1 where col1=1;
drop table t1;
--echo End of 10.5 tests

View File

@@ -686,3 +686,40 @@ SELECT * FROM t1;
id
1
DROP TABLE t1;
#
# MDEV-34883: LOAD DATA INFILE with geometry data fails
#
CREATE OR REPLACE TABLE t1 (
p point NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO t1 VALUES (GeomFromText('POINT(37.646944 -75.761111)'));
SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/t1.tsv' FROM t1;
CREATE OR REPLACE TABLE t2 LIKE t1;
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/t1.tsv' INTO TABLE t2;
drop table t1, t2;
CREATE OR REPLACE TABLE t1 (
p point NOT NULL,
chr char(20)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO t1 VALUES (GeomFromText('POINT(37.646944 -75.761111)'),"їєі");
SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/t1.tsv' FROM t1;
CREATE OR REPLACE TABLE t2 LIKE t1;
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/t1.tsv' INTO TABLE t2 CHARACTER SET latin1;
select ST_AsText(p), chr from t1;
ST_AsText(p) chr
POINT(37.646944 -75.761111) їєі
# incorrect string (but correct geom)
select ST_AsText(p), chr from t2;
ST_AsText(p) chr
POINT(37.646944 -75.761111) їєі
delete from t2;
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/t1.tsv' INTO TABLE t2 CHARACTER SET utf8mb4;
select ST_AsText(p), chr from t1;
ST_AsText(p) chr
POINT(37.646944 -75.761111) їєі
# all is correct
select ST_AsText(p), chr from t2;
ST_AsText(p) chr
POINT(37.646944 -75.761111) їєі
drop table t1, t2;
# End of 10.5 tests

View File

@@ -832,3 +832,61 @@ CREATE TABLE t1 (id integer not null auto_increment primary key);
LOAD DATA INFILE '../../std_data/loaddata/nl.txt' INTO TABLE t1 FIELDS TERMINATED BY '';
SELECT * FROM t1;
DROP TABLE t1;
--echo #
--echo # MDEV-34883: LOAD DATA INFILE with geometry data fails
--echo #
CREATE OR REPLACE TABLE t1 (
p point NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO t1 VALUES (GeomFromText('POINT(37.646944 -75.761111)'));
--disable_ps2_protocol
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t1.tsv' FROM t1;
--enable_ps2_protocol
CREATE OR REPLACE TABLE t2 LIKE t1;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/t1.tsv' INTO TABLE t2;
--remove_file '$MYSQLTEST_VARDIR/tmp/t1.tsv'
drop table t1, t2;
CREATE OR REPLACE TABLE t1 (
p point NOT NULL,
chr char(20)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO t1 VALUES (GeomFromText('POINT(37.646944 -75.761111)'),"їєі");
--disable_ps2_protocol
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t1.tsv' FROM t1;
--enable_ps2_protocol
CREATE OR REPLACE TABLE t2 LIKE t1;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/t1.tsv' INTO TABLE t2 CHARACTER SET latin1;
select ST_AsText(p), chr from t1;
--echo # incorrect string (but correct geom)
select ST_AsText(p), chr from t2;
delete from t2;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/t1.tsv' INTO TABLE t2 CHARACTER SET utf8mb4;
select ST_AsText(p), chr from t1;
--echo # all is correct
select ST_AsText(p), chr from t2;
--remove_file '$MYSQLTEST_VARDIR/tmp/t1.tsv'
drop table t1, t2;
--echo # End of 10.5 tests

View File

@@ -216,7 +216,7 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=EXAMPLE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci `VAROPT`=33
) ENGINE=EXAMPLE DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci `varopt`=33
drop table t1;
SET @@SQL_MODE=@OLD_SQL_MODE;
select 1;

View File

@@ -325,6 +325,19 @@ PREPARE stmt FROM "UPDATE t SET a = 0 LIMIT ?";
EXECUTE stmt USING 0;
EXECUTE stmt USING 1;
DROP TABLE t;
#
# MDEV-35249: Assertion `(mem_root->flags & 4) == 0' failed in convert_subq_to_jtbm
#
CREATE TABLE t (a INT, b INT, c INT);
INSERT INTO t VALUES (1,2,3),(4,5,6);
CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t;
CREATE VIEW v2 AS SELECT * FROM v1;
PREPARE stmt FROM 'UPDATE t SET a = 0 WHERE b IN (SELECT c FROM v2)';
EXECUTE stmt;
EXECUTE stmt;
DROP VIEW v2;
DROP VIEW v1;
DROP TABLE t;
# End of 10.5 tests
#
# MDEV-33769: Memory leak found in the test main.rownum run with --ps-protocol against a server built with the option -DWITH_PROTECT_STATEMENT_MEMROOT

View File

@@ -323,6 +323,23 @@ EXECUTE stmt USING 1;
# CLeanup
DROP TABLE t;
--echo #
--echo # MDEV-35249: Assertion `(mem_root->flags & 4) == 0' failed in convert_subq_to_jtbm
--echo #
CREATE TABLE t (a INT, b INT, c INT);
INSERT INTO t VALUES (1,2,3),(4,5,6);
CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t;
CREATE VIEW v2 AS SELECT * FROM v1;
PREPARE stmt FROM 'UPDATE t SET a = 0 WHERE b IN (SELECT c FROM v2)';
EXECUTE stmt;
EXECUTE stmt;
# Cleanup
DROP VIEW v2;
DROP VIEW v1;
DROP TABLE t;
--echo # End of 10.5 tests
--echo #

View File

@@ -2448,9 +2448,17 @@ SELECT * FROM t1;
a b total
10 20 30
DROP TABLE t1;
#
# End of 10.3 tests
#
# MDEV-32022 ERROR 1054 (42S22): Unknown column 'X' in 'NEW' in trigger
#
create table t1 (m set('sms') not null);
create table t2 (i int);
create table t3 (j int);
create trigger t1 after insert on t1 for each row insert ignore into t2 select t3.j from t3 join (select 'sms' as method) m on find_in_set(m.method, new.m);
insert into t1 values ('sms');
drop table t1, t2, t3;
# End of 10.5 tests
#
# Test dropping orphan .trn file
#
@@ -2486,6 +2494,4 @@ Error 1360 Trigger does not exist
Warning 4181 Dropped orphan trigger 't1_trg', originally created for table: 't1'
drop trigger t1_trg_2;
drop table t1;
#
# End of 10.6 tests
#

View File

@@ -2788,9 +2788,19 @@ INSERT INTO t1 (a,b) VALUES (10, 20);
SELECT * FROM t1;
DROP TABLE t1;
--echo #
--echo # End of 10.3 tests
--echo #
--echo # MDEV-32022 ERROR 1054 (42S22): Unknown column 'X' in 'NEW' in trigger
--echo #
create table t1 (m set('sms') not null);
create table t2 (i int);
create table t3 (j int);
create trigger t1 after insert on t1 for each row insert ignore into t2 select t3.j from t3 join (select 'sms' as method) m on find_in_set(m.method, new.m);
insert into t1 values ('sms');
drop table t1, t2, t3;
--echo # End of 10.5 tests
--echo #
--echo # Test dropping orphan .trn file
@@ -2833,6 +2843,4 @@ drop trigger t1_trg_2;
drop table t1;
--remove_file $MYSQLD_DATADIR/test/t1_trg.TMP
--echo #
--echo # End of 10.6 tests
--echo #

View File

@@ -10,6 +10,7 @@ wsrep-provider=@ENV.WSREP_PROVIDER
# enforce read-committed characteristics across the cluster
# wsrep-causal-reads=ON
wsrep-sync-wait=15
wsrep-debug=1
[mysqld.1]
wsrep-on=1
@@ -17,7 +18,7 @@ wsrep-on=1
#ist_port=@OPT.port
#sst_port=@OPT.port
wsrep_cluster_address=gcomm://
wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.1.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT15S;gcache.size=10M'
wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.1.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT25S'
wsrep_node_address='127.0.0.1:@mysqld.1.#galera_port'
wsrep_node_incoming_address=127.0.0.1:@mysqld.1.port
wsrep_sst_receive_address='127.0.0.1:@mysqld.1.#sst_port'
@@ -29,7 +30,7 @@ wsrep-on=1
#ist_port=@OPT.port
#sst_port=@OPT.port
wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port'
wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.2.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT15S;gcache.size=10M'
wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.2.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT25S'
wsrep_node_address='127.0.0.1:@mysqld.2.#galera_port'
wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port
wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port'
@@ -41,7 +42,7 @@ wsrep-on=1
#ist_port=@OPT.port
#sst_port=@OPT.port
wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port'
wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.3.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT15S;gcache.size=10M'
wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.3.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT25S'
wsrep_node_address='127.0.0.1:@mysqld.3.#galera_port'
wsrep_node_incoming_address=127.0.0.1:@mysqld.3.port
wsrep_sst_receive_address='127.0.0.1:@mysqld.3.#sst_port'
@@ -53,7 +54,7 @@ wsrep-on=1
#ist_port=@OPT.port
#sst_port=@OPT.port
wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port'
wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.4.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT15S;gcache.size=10M'
wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.4.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT25S'
wsrep_node_address='127.0.0.1:@mysqld.4.#galera_port'
wsrep_node_incoming_address=127.0.0.1:@mysqld.4.port
wsrep_sst_receive_address='127.0.0.1:@mysqld.4.#sst_port'

View File

@@ -8,7 +8,7 @@ connection node_1;
SET @@enforce_storage_engine=INNODB;
CREATE TABLE t1(i INT) ENGINE=INNODB;
CREATE TABLE t2(i INT) ENGINE=MYISAM;
ERROR 42000: Unknown storage engine 'MyISAM'
ERROR HY000: The MariaDB server is running with the NO_ENGINE_SUBSTITUTION option so it cannot execute this statement
INSERT INTO t1 VALUES(1);
connection node_2;
SHOW TABLES;

View File

@@ -6,6 +6,8 @@ connection node_1;
connection node_2;
connection node_3;
connection node_4;
connection node_1;
SET GLOBAL wsrep_provider_options = 'pc.weight=2';
connection node_3;
SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 1';
connection node_1;
@@ -44,7 +46,8 @@ COUNT(*) = 0
1
CALL mtr.add_suppression("mariadbd: Can't find record in 't1'");
CALL mtr.add_suppression("Slave SQL: Could not execute Delete_rows");
CALL mtr.add_suppression("WSREP: Event 3 Delete_rows_v1 apply failed: 120, seqno [0-9]*");
CALL mtr.add_suppression("WSREP: Event 3 Delete_rows_v1 apply failed: 120, seqno ");
SET GLOBAL wsrep_provider_options = 'pc.weight=1';
connection node_2;
SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'A';
COUNT(*) = 1
@@ -54,7 +57,7 @@ COUNT(*) = 0
1
CALL mtr.add_suppression("mariadbd: Can't find record in 't1'");
CALL mtr.add_suppression("Slave SQL: Could not execute Delete_rows");
CALL mtr.add_suppression("WSREP: Event 3 Delete_rows_v1 apply failed: 120, seqno [0-9]*");
CALL mtr.add_suppression("WSREP: Event 3 Delete_rows_v1 apply failed: 120, seqno ");
connection node_3;
SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'A';
COUNT(*) = 1

View File

@@ -8,16 +8,30 @@ SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_N
VARIABLE_VALUE = 4
1
connection node_1;
CREATE TABLE t1 (f1 INTEGER);
CREATE TABLE t1 (f1 INTEGER NOT NULL PRIMARY KEY) ENGINE=INNODB;
connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3;
connection node_3;
SELECT COUNT(*) AS EXPECT_0 FROM t1;
EXPECT_0
0
INSERT INTO t1 VALUES (1);
SELECT COUNT(*) AS EXPECT_1 FROM t1;
EXPECT_1
1
connection node_2;
SELECT COUNT(*) AS EXPECT_1 FROM t1;
EXPECT_1
1
connection node_1;
SELECT COUNT(*) AS EXPECT_1 FROM t1;
EXPECT_1
1
connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4;
connection node_4;
SELECT COUNT(*) AS EXPECT_1 FROM t1;
EXPECT_1
1
SELECT VARIABLE_VALUE LIKE '%gmcast.segment = 3%' FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'wsrep_provider_options';
VARIABLE_VALUE LIKE '%gmcast.segment = 3%'
1
SELECT COUNT(*) = 1 FROM t1;
COUNT(*) = 1
1
DROP TABLE t1;

View File

@@ -13,7 +13,7 @@
--connection node_1
SET @@enforce_storage_engine=INNODB;
CREATE TABLE t1(i INT) ENGINE=INNODB;
--error ER_UNKNOWN_STORAGE_ENGINE
--error ER_OPTION_PREVENTS_STATEMENT
CREATE TABLE t2(i INT) ENGINE=MYISAM;
INSERT INTO t1 VALUES(1);

View File

@@ -2,6 +2,7 @@
[mysqld]
wsrep-ignore-apply-errors=0
loose-galera-vote-rejoin-dml=0
[ENV]
galera_cluster_size=4

View File

@@ -5,6 +5,10 @@
--source include/galera_cluster.inc
--source include/big_test.inc
--source include/force_restart.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc
--let $node_1=node_1
--let $node_2=node_2
@@ -12,6 +16,9 @@
--let $node_4=node_4
--source include/auto_increment_offset_save.inc
--connection node_1
SET GLOBAL wsrep_provider_options = 'pc.weight=2';
# Isolate node #3
--connection node_3
SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 1';
@@ -30,6 +37,7 @@ INSERT INTO t1 VALUES (1, 'A');
SET SESSION wsrep_on=OFF;
INSERT INTO t1 VALUES (2, 'B');
SET SESSION wsrep_on=ON;
--source include/galera_wait_ready.inc
DELETE FROM t1 WHERE f1 = 2;
# Wait for node #4 to be voted out
@@ -75,14 +83,15 @@ SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'A';
SELECT COUNT(*) = 0 FROM t1 WHERE f2 = 'B';
CALL mtr.add_suppression("mariadbd: Can't find record in 't1'");
CALL mtr.add_suppression("Slave SQL: Could not execute Delete_rows");
CALL mtr.add_suppression("WSREP: Event 3 Delete_rows_v1 apply failed: 120, seqno [0-9]*");
CALL mtr.add_suppression("WSREP: Event 3 Delete_rows_v1 apply failed: 120, seqno ");
SET GLOBAL wsrep_provider_options = 'pc.weight=1';
--connection node_2
SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'A';
SELECT COUNT(*) = 0 FROM t1 WHERE f2 = 'B';
CALL mtr.add_suppression("mariadbd: Can't find record in 't1'");
CALL mtr.add_suppression("Slave SQL: Could not execute Delete_rows");
CALL mtr.add_suppression("WSREP: Event 3 Delete_rows_v1 apply failed: 120, seqno [0-9]*");
CALL mtr.add_suppression("WSREP: Event 3 Delete_rows_v1 apply failed: 120, seqno ");
--connection node_3
SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'A';

View File

@@ -1,5 +1,8 @@
!include ../galera_4nodes.cnf
[mysqld]
loose-galera-wan=1
[mysqld.1]
wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=10M;gmcast.segment=1'

View File

@@ -8,31 +8,35 @@
--source include/galera_cluster.inc
--source include/have_innodb.inc
--source include/force_restart.inc
CALL mtr.add_suppression("WSREP: Stray state UUID msg:");
CALL mtr.add_suppression("Sending JOIN failed: ");
CALL mtr.add_suppression("WSREP: .* sending install message failed: Socket is not connected");
CALL mtr.add_suppression("There are no nodes in the same segment that will ever be able to become donors, yet there is a suitable donor outside");
--let $wait_condition = SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc
SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--connection node_1
CREATE TABLE t1 (f1 INTEGER);
CREATE TABLE t1 (f1 INTEGER NOT NULL PRIMARY KEY) ENGINE=INNODB;
--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
--connection node_3
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t1';
--source include/wait_condition.inc
SELECT COUNT(*) AS EXPECT_0 FROM t1;
INSERT INTO t1 VALUES (1);
SELECT COUNT(*) AS EXPECT_1 FROM t1;
--connection node_2
SELECT COUNT(*) AS EXPECT_1 FROM t1;
--connection node_1
SELECT COUNT(*) AS EXPECT_1 FROM t1;
--connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4
--connection node_4
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t1';
--source include/wait_condition.inc
--let $wait_condition = SELECT COUNT(*) = 1 FROM t1;
--source include/wait_condition.inc
SELECT COUNT(*) AS EXPECT_1 FROM t1;
SELECT VARIABLE_VALUE LIKE '%gmcast.segment = 3%' FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'wsrep_provider_options';
SELECT COUNT(*) = 1 FROM t1;
DROP TABLE t1;

View File

@@ -1,5 +1,8 @@
!include ../galera_4nodes.cnf
[mysqld]
loose-galera-wan-restart-ist=1
[mysqld.1]
wsrep_provider_options='base_port=@mysqld.1.#galera_port;gmcast.segment=1'

View File

@@ -15,6 +15,9 @@
--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
--connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4
--let $wait_condition = SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc
# Save original auto_increment_offset values.
--let $node_1=node_1
--let $node_2=node_2
@@ -22,9 +25,6 @@
--let $node_4=node_4
--source include/auto_increment_offset_save.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc
SELECT VARIABLE_VALUE AS EXPECT_4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--connection node_1

View File

@@ -1,5 +1,8 @@
!include ../galera_4nodes.cnf
[mysqld]
loose-galera-wan-restart-sst=1
[mysqld.1]
wsrep_provider_options='base_port=@mysqld.1.#galera_port;gmcast.segment=1'

View File

@@ -11,10 +11,14 @@
--source include/big_test.inc
--source include/galera_cluster.inc
--source include/have_innodb.inc
--source include/force_restart.inc
--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
--connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4
--let $wait_condition = SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc
# Save original auto_increment_offset values.
--let $node_1=node_1
--let $node_2=node_2
@@ -22,8 +26,6 @@
--let $node_4=node_4
--source include/auto_increment_offset_save.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc
SELECT VARIABLE_VALUE AS EXPECT_4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--connection node_1

View File

@@ -0,0 +1,21 @@
#
# MDEV-35144 CREATE TABLE ... LIKE uses current innodb_compression_default instead of the create value
#
set innodb_compression_default= off;
create table t1 (a int, b blob) engine=innodb;
set innodb_compression_default= on;
create table s_import like t1;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` blob DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
show create table s_import;
Table Create Table
s_import CREATE TABLE `s_import` (
`a` int(11) DEFAULT NULL,
`b` blob DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DROP TABLE t1,s_import;
# End of 10.5 tests

View File

@@ -8,3 +8,13 @@ connection default;
ERROR 70100: Query execution was interrupted
CREATE TABLE t1 (a SERIAL) ENGINE=InnoDB;
DROP TABLE t1;
# End of 10.2 tests
#
# MDEV-35236 Assertion `(mem_root->flags & 4) == 0' failed in safe_lexcstrdup_root
#
prepare stmt from 'create or replace table t engine=innodb select 1 as f';
set innodb_compression_default=on;
execute stmt;
execute stmt;
drop table t;
# End of 10.5 tests

View File

@@ -526,6 +526,15 @@ c INT as (b) VIRTUAL)ENGINE=InnoDB CHARACTER SET utf32;
ALTER TABLE t1 DROP COLUMN a;
ALTER TABLE t1 DROP COLUMN c;
DROP TABLE t1;
#
# MDEV-35122 Incorrect NULL value handling for instantly
# dropped BLOB columns
#
CREATE TABLE t1 (c1 INT, c2 BLOB, c3 BLOB NOT NULL) ROW_FORMAT=REDUNDANT,ENGINE=InnoDB;
ALTER TABLE t1 DROP c2;
ALTER TABLE t1 DROP c3;
INSERT INTO t1 VALUES(1);
DROP TABLE t1;
# End of 10.5 tests
# End of 10.6 tests
SET GLOBAL innodb_stats_persistent = @save_stats_persistent;

View File

@@ -50,6 +50,7 @@ SELECT * FROM INFORMATION_SCHEMA.ENGINES
WHERE engine = 'innodb'
AND support IN ('YES', 'DEFAULT', 'ENABLED');
ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS
FOUND 1 /InnoDB: Could not measure the size of single-table tablespace file '.*test/t2\.ibd'/ in mysqld.1.err
# restart
SELECT * FROM INFORMATION_SCHEMA.ENGINES
WHERE engine = 'innodb'

View File

@@ -0,0 +1,6 @@
create table t_compressed(b longblob) engine=InnoDB page_compressed=1;
insert into t_compressed values(repeat(1,1000000));
select allocated_size < file_size from information_schema.innodb_sys_tablespaces where name='test/t_compressed';
allocated_size < file_size
1
drop table t_compressed;

View File

@@ -0,0 +1,16 @@
--source include/have_innodb.inc
--echo #
--echo # MDEV-35144 CREATE TABLE ... LIKE uses current innodb_compression_default instead of the create value
--echo #
set innodb_compression_default= off;
create table t1 (a int, b blob) engine=innodb;
set innodb_compression_default= on;
create table s_import like t1;
show create table t1;
show create table s_import;
DROP TABLE t1,s_import;
--echo # End of 10.5 tests

View File

@@ -26,3 +26,16 @@ reap;
CREATE TABLE t1 (a SERIAL) ENGINE=InnoDB;
DROP TABLE t1;
--source include/wait_until_count_sessions.inc
--echo # End of 10.2 tests
--echo #
--echo # MDEV-35236 Assertion `(mem_root->flags & 4) == 0' failed in safe_lexcstrdup_root
--echo #
prepare stmt from 'create or replace table t engine=innodb select 1 as f';
set innodb_compression_default=on;
execute stmt;
execute stmt;
drop table t;
--echo # End of 10.5 tests

View File

@@ -567,6 +567,16 @@ ALTER TABLE t1 DROP COLUMN a;
ALTER TABLE t1 DROP COLUMN c;
DROP TABLE t1;
--echo #
--echo # MDEV-35122 Incorrect NULL value handling for instantly
--echo # dropped BLOB columns
--echo #
CREATE TABLE t1 (c1 INT, c2 BLOB, c3 BLOB NOT NULL) ROW_FORMAT=REDUNDANT,ENGINE=InnoDB;
ALTER TABLE t1 DROP c2;
ALTER TABLE t1 DROP c3;
INSERT INTO t1 VALUES(1);
DROP TABLE t1;
--echo # End of 10.5 tests
--echo # End of 10.6 tests

View File

@@ -94,6 +94,7 @@ let SEARCH_PATTERN= InnoDB: Set innodb_force_recovery=1 to ignore this and to pe
--source include/start_mysqld.inc
eval $check_no_innodb;
--let $on_linux= `select @@version_compile_os LIKE 'Linux%'`
--source include/shutdown_mysqld.inc
let SEARCH_PATTERN= InnoDB: Tablespace \d+ was not found at .*t[12].ibd.
@@ -107,9 +108,18 @@ let SEARCH_PATTERN= InnoDB: Tablespace \d+ was not found at .*t[12].ibd.
--source include/start_mysqld.inc
eval $check_no_innodb;
--source include/shutdown_mysqld.inc
# On Windows, this error message is not output when t2.ibd is a directory!
#let SEARCH_PATTERN= \[Note\] InnoDB: Cannot read first page of .*t2.ibd;
#--source include/search_pattern_in_file.inc
--let SEARCH_PATTERN= InnoDB: Could not measure the size of single-table tablespace file '.*test/t2\\.ibd'
if (!$on_linux)
{
# os_file_get_size() would succeed on a directory.
--echo FOUND 1 /$SEARCH_PATTERN/ in mysqld.1.err
}
if ($on_linux)
{
# lseek() reports EINVAL when invoked on a directory.
--source include/search_pattern_in_file.inc
}
--rmdir $MYSQLD_DATADIR/test/t2.ibd
@@ -148,10 +158,11 @@ DROP TABLE t0;
--disable_query_log
# The following are for the orphan file t0.ibd or for the directory t2.ibd:
call mtr.add_suppression("InnoDB: Operating system error number [0-9]* in a file operation");
call mtr.add_suppression("InnoDB: Error number [0-9]* means '(File exists|Is a directory)'");
call mtr.add_suppression("InnoDB: Error number [0-9]* means '(File exists|Is a directory|Invalid argument)'");
call mtr.add_suppression("InnoDB: Cannot create file '.*t0.ibd'");
call mtr.add_suppression("InnoDB: The file '.*t0\.ibd' already exists");
call mtr.add_suppression("InnoDB: Cannot open datafile for read-write: '.*t2\.ibd'");
call mtr.add_suppression("InnoDB: Could not measure the size of single-table tablespace file '.*test/t2\\.ibd'");
# The following are for aborted startup without --innodb-force-recovery:
call mtr.add_suppression("InnoDB: Tablespace .* was not found at .*test");
call mtr.add_suppression("InnoDB: Set innodb_force_recovery=1 to ignore this and to permanently lose all changes to the tablespace");

View File

@@ -0,0 +1 @@
--innodb-sys-tablespaces

View File

@@ -0,0 +1,7 @@
--source include/have_innodb.inc
--source include/windows.inc
create table t_compressed(b longblob) engine=InnoDB page_compressed=1;
insert into t_compressed values(repeat(1,1000000));
# Check that compression worked, i.e allocated size (physical file size) < logical file size
select allocated_size < file_size from information_schema.innodb_sys_tablespaces where name='test/t_compressed';
drop table t_compressed;

View File

@@ -784,3 +784,28 @@ f1 MATCH(f1) AGAINST ("test" IN BOOLEAN MODE)
test 0.000000001885928302414186
DROP TABLE t1;
# End of 10.3 tests
#
# MDEV-35183 ADD FULLTEXT INDEX unnecessarily DROPS FTS
# COMMON TABLES
#
CREATE TABLE t1 (
ID INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
title VARCHAR(200), book VARCHAR(200),
FULLTEXT fidx(title)) ENGINE = InnoDB;
INSERT INTO t1(title) VALUES('database');
ALTER TABLE t1 DROP INDEX fidx;
select space into @common_space from information_schema.innodb_sys_tables where name like "test/FTS_%_CONFIG";
ALTER TABLE t1 ADD FULLTEXT fidx_1(book);
select space=@common_space from information_schema.innodb_sys_tables where name like "test/FTS_%_CONFIG";
space=@common_space
1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(200) DEFAULT NULL,
`book` varchar(200) DEFAULT NULL,
PRIMARY KEY (`ID`),
FULLTEXT KEY `fidx_1` (`book`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DROP TABLE t1;

View File

@@ -803,3 +803,19 @@ SELECT f1, MATCH(f1) AGAINST ("test" IN BOOLEAN MODE) FROM t1;
DROP TABLE t1;
--echo # End of 10.3 tests
--echo #
--echo # MDEV-35183 ADD FULLTEXT INDEX unnecessarily DROPS FTS
--echo # COMMON TABLES
--echo #
CREATE TABLE t1 (
ID INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
title VARCHAR(200), book VARCHAR(200),
FULLTEXT fidx(title)) ENGINE = InnoDB;
INSERT INTO t1(title) VALUES('database');
ALTER TABLE t1 DROP INDEX fidx;
select space into @common_space from information_schema.innodb_sys_tables where name like "test/FTS_%_CONFIG";
ALTER TABLE t1 ADD FULLTEXT fidx_1(book);
select space=@common_space from information_schema.innodb_sys_tables where name like "test/FTS_%_CONFIG";
SHOW CREATE TABLE t1;
DROP TABLE t1;

View File

@@ -302,16 +302,91 @@ drop sequence s;
# End of 10.4 tests
#
#
# MDEV-32350 Can't selectively restore sequences using innodb tables from
# backup
#
create sequence s2 engine=innodb;
alter table s2 discard tablespace;
SELECT NEXTVAL(s2);
ERROR HY000: Got error 194 "Tablespace is missing for a table" from storage engine InnoDB
create sequence s1 engine=innodb;
select * from s1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
1 1 9223372036854775806 1 1 1000 0 0
flush tables s1 for export;
unlock tables;
select * from s2;
ERROR HY000: Got error 194 "Tablespace is missing for a table" from storage engine InnoDB
SELECT NEXTVAL(s2);
ERROR HY000: Got error 194 "Tablespace is missing for a table" from storage engine InnoDB
alter sequence s2 restart;
ERROR HY000: Got error 194 "Tablespace is missing for a table" from storage engine InnoDB
alter table s2 import tablespace;
select * from s2;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
1 1 9223372036854775806 1 1 1000 0 0
SELECT NEXTVAL(s2);
NEXTVAL(s2)
1
select NEXTVAL(s1);
NEXTVAL(s1)
1
flush table s1,s2;
select * from s1;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
1001 1 9223372036854775806 1 1 1000 0 0
select * from s2;
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
1001 1 9223372036854775806 1 1 1000 0 0
drop sequence s1,s2;
#
# MDEV-35144 CREATE TABLE ... LIKE uses current innodb_compression_default instead of the create value
#
set @@innodb_compression_default= off;
create or replace sequence s engine=innodb;
set @@innodb_compression_default= on;
create or replace table s_import like s;
show create table s;
Table Create Table
s CREATE TABLE `s` (
`next_not_cached_value` bigint(21) NOT NULL,
`minimum_value` bigint(21) NOT NULL,
`maximum_value` bigint(21) NOT NULL,
`start_value` bigint(21) NOT NULL COMMENT 'start value when sequences is created or value if RESTART is used',
`increment` bigint(21) NOT NULL COMMENT 'increment value',
`cache_size` bigint(21) unsigned NOT NULL,
`cycle_option` tinyint(1) unsigned NOT NULL COMMENT '0 if no cycles are allowed, 1 if the sequence should begin a new cycle when maximum_value is passed',
`cycle_count` bigint(21) NOT NULL COMMENT 'How many cycles have been done'
) ENGINE=InnoDB SEQUENCE=1
show create table s_import;
Table Create Table
s_import CREATE TABLE `s_import` (
`next_not_cached_value` bigint(21) NOT NULL,
`minimum_value` bigint(21) NOT NULL,
`maximum_value` bigint(21) NOT NULL,
`start_value` bigint(21) NOT NULL COMMENT 'start value when sequences is created or value if RESTART is used',
`increment` bigint(21) NOT NULL COMMENT 'increment value',
`cache_size` bigint(21) unsigned NOT NULL,
`cycle_option` tinyint(1) unsigned NOT NULL COMMENT '0 if no cycles are allowed, 1 if the sequence should begin a new cycle when maximum_value is passed',
`cycle_count` bigint(21) NOT NULL COMMENT 'How many cycles have been done'
) ENGINE=InnoDB SEQUENCE=1
alter table s_import discard tablespace;
flush table s for export;
UNLOCK TABLES;
alter table s_import import tablespace;
drop table s,s_import;
# End of 10.5 tests
#
# MDEV-31607 ER_DUP_KEY in mysql.table_stats upon REANME on sequence
#
CREATE SEQUENCE s1 ENGINE=InnoDB;
CREATE SEQUENCE s2 ENGINE=InnoDB;
SHOW CREATE SEQUENCE s1;
Table Create Table
s1 CREATE SEQUENCE `s1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB
s1 CREATE SEQUENCE `s1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB `PAGE_COMPRESSED`='ON'
SHOW CREATE SEQUENCE s2;
Table Create Table
s2 CREATE SEQUENCE `s2` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB
s2 CREATE SEQUENCE `s2` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB `PAGE_COMPRESSED`='ON'
DROP SEQUENCE s2;
RENAME TABLE s1 TO s2;
DROP SEQUENCE s2;

View File

@@ -202,6 +202,63 @@ drop sequence s;
--echo # End of 10.4 tests
--echo #
--echo #
--echo # MDEV-32350 Can't selectively restore sequences using innodb tables from
--echo # backup
--echo #
--disable_ps_protocol
create sequence s2 engine=innodb;
alter table s2 discard tablespace;
--error ER_GET_ERRNO
SELECT NEXTVAL(s2);
create sequence s1 engine=innodb;
select * from s1;
flush tables s1 for export;
--let $MYSQLD_DATADIR= `select @@datadir`
--move_file $MYSQLD_DATADIR/test/s1.cfg $MYSQLD_DATADIR/test/s2.cfg
--copy_file $MYSQLD_DATADIR/test/s1.ibd $MYSQLD_DATADIR/test/s2.ibd
unlock tables;
--error ER_GET_ERRNO
select * from s2;
--error ER_GET_ERRNO
SELECT NEXTVAL(s2);
--error ER_GET_ERRNO
alter sequence s2 restart;
alter table s2 import tablespace;
select * from s2;
SELECT NEXTVAL(s2);
select NEXTVAL(s1);
flush table s1,s2;
select * from s1;
select * from s2;
drop sequence s1,s2;
--enable_ps_protocol
--echo #
--echo # MDEV-35144 CREATE TABLE ... LIKE uses current innodb_compression_default instead of the create value
--echo #
set @@innodb_compression_default= off;
create or replace sequence s engine=innodb;
set @@innodb_compression_default= on;
create or replace table s_import like s;
show create table s;
show create table s_import;
alter table s_import discard tablespace;
flush table s for export;
--copy_file $MYSQLD_DATADIR/test/s.ibd $MYSQLD_DATADIR/test/s_import.ibd
--copy_file $MYSQLD_DATADIR/test/s.cfg $MYSQLD_DATADIR/test/s_import.cfg
UNLOCK TABLES;
alter table s_import import tablespace;
drop table s,s_import;
--echo # End of 10.5 tests
--echo #
--echo # MDEV-31607 ER_DUP_KEY in mysql.table_stats upon REANME on sequence
--echo #

View File

@@ -724,3 +724,34 @@ ERROR HY000: Sequence 'test.s' table structure is invalid (Wrong number of colum
#
# End of 10.4 test
#
#
# Ensure that SHOW CREATE TABLE shows used table options
#
SET @@innodb_compression_default=ON;
CREATE TABLE seq (
`next_not_cached_value` bigint(21) NOT NULL,
`minimum_value` bigint(21) NOT NULL,
`maximum_value` bigint(21) NOT NULL,
`start_value` bigint(21) NOT NULL,
`increment` bigint(21) NOT NULL,
`cache_size` bigint(21) unsigned NOT NULL,
`cycle_option` tinyint(1) unsigned NOT NULL,
`cycle_count` bigint(21) NOT NULL
) engine=innodb,sequence=1;
show create sequence seq;
Table Create Table
seq CREATE SEQUENCE `seq` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB `PAGE_COMPRESSED`='ON'
show create table seq;
Table Create Table
seq CREATE TABLE `seq` (
`next_not_cached_value` bigint(21) NOT NULL,
`minimum_value` bigint(21) NOT NULL,
`maximum_value` bigint(21) NOT NULL,
`start_value` bigint(21) NOT NULL,
`increment` bigint(21) NOT NULL,
`cache_size` bigint(21) unsigned NOT NULL,
`cycle_option` tinyint(1) unsigned NOT NULL,
`cycle_count` bigint(21) NOT NULL
) ENGINE=InnoDB SEQUENCE=1 `PAGE_COMPRESSED`='ON'
drop sequence seq;
SET @@innodb_compression_default=DEFAULT;

View File

@@ -565,3 +565,23 @@ create table s sequence=1 as select 1;
--echo #
--echo # End of 10.4 test
--echo #
--echo #
--echo # Ensure that SHOW CREATE TABLE shows used table options
--echo #
SET @@innodb_compression_default=ON;
CREATE TABLE seq (
`next_not_cached_value` bigint(21) NOT NULL,
`minimum_value` bigint(21) NOT NULL,
`maximum_value` bigint(21) NOT NULL,
`start_value` bigint(21) NOT NULL,
`increment` bigint(21) NOT NULL,
`cache_size` bigint(21) unsigned NOT NULL,
`cycle_option` tinyint(1) unsigned NOT NULL,
`cycle_count` bigint(21) NOT NULL
) engine=innodb,sequence=1;
show create sequence seq;
show create table seq;
drop sequence seq;
SET @@innodb_compression_default=DEFAULT;

View File

@@ -27,6 +27,7 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c my_default.c
my_alloc.c my_bit.c my_bitmap.c my_chsize.c
my_compress.c my_copy.c my_create.c my_delete.c
my_div.c my_error.c my_file.c my_fopen.c my_fstream.c
my_getexe.c
my_gethwaddr.c my_getopt.c my_getsystime.c my_getwd.c my_compare.c my_init.c
my_lib.c my_lock.c my_malloc.c my_mess.c
my_mkdir.c my_mmap.c my_once.c my_open.c my_pread.c my_pthread.c
@@ -35,7 +36,7 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c my_default.c
my_basename.c
my_write.c ptr_cmp.c queues.c stacktrace.c
string.c thr_alarm.c thr_lock.c thr_mutex.c
thr_rwlock.c thr_timer.c
thr_rwlock.c thr_timer.c my_stack.c
tree.c typelib.c base64.c my_memmem.c
my_getpagesize.c
guess_malloc_library.c

66
mysys/my_getexe.c Normal file
View File

@@ -0,0 +1,66 @@
/* Copyright (c) 2017, MariaDB Plc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
#include <my_global.h>
#include <my_sys.h>
#ifdef _WIN32
#elif defined(__linux__)
#include <unistd.h>
#elif defined(__APPLE__)
#include <libproc.h>
#elif defined(__FreeBSD__)
#include <sys/sysctl.h>
#elif defined(__NetBSD__)
#include <sys/param.h>
#include <sys/sysctl.h>
#endif
/** Fill the buffer with the executable program name
@param[out] buf buffer to place obtained executable name.
@param[in] size size available in the buffer.
@param[in] argv0 the argv0 from which the executable argv might be used.
@return 0, for successful filling of buf, non-zero for failure. */
int my_get_exepath(char *buf, size_t size, const char *argv0)
{
#ifdef _WIN32
DWORD ret = GetModuleFileNameA(NULL, buf, (DWORD)size);
if (ret > 0)
return 0;
#elif defined(__linux__)
ssize_t ret = readlink("/proc/self/exe", buf, size-1);
if(ret > 0)
return 0;
#elif defined(__APPLE__)
size_t ret = proc_pidpath(getpid(), buf, (uint32_t)size);
if (ret > 0) {
buf[ret] = 0;
return 0;
}
#elif defined(__FreeBSD__)
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
if (sysctl(mib, 4, buf, &size, NULL, 0) == 0) {
return 0;
}
#elif defined(__NetBSD__)
int mib[4] = {CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME };
if (sysctl(mib, 4, buf, &size, NULL, 0) == 0)
return 0;
#endif
if (argv0)
return my_realpath(buf, argv0, 0);
return 1;
}

95
mysys/my_stack.c Normal file
View File

@@ -0,0 +1,95 @@
/* Copyright 2024 MariaDB corporation AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
*/
/*
Get start and end of stack
Note that the code depends on STACK_DIRECTION that is defined by cmake.
In general, STACK_DIRECTION should be 1 except in case of
an upward-growing stack that can happen on sparc or hpux platforms.
*/
#include "my_global.h"
#include "my_sys.h"
#include "my_stack_alloc.h"
#ifdef _WIN_
#include <windows.h>
#include <processthreadsapi.h>
#include <winnt.h>
#endif
/* Get start and end of stack */
extern void my_get_stack_bounds(void **stack_start, void **stack_end,
void *fallback_stack_start,
size_t fallback_stack_size)
{
#if defined(__GNUC__) || defined(__clang__) /* GCC or Clang compilers */
size_t stack_size;
#if defined(HAVE_PTHREAD_GETATTR_NP)
/* POSIX-compliant system (Linux, macOS, etc.) */
pthread_attr_t attr;
pthread_t thread= pthread_self();
void *stack_base;
/* Get the thread attributes */
if (pthread_getattr_np(thread, &attr) == 0)
{
/* Get stack base and size */
pthread_attr_getstack(&attr, &stack_base, &stack_size);
/*
stack_base points to start of the stack region to which the
stack grows to
*/
*stack_start= stack_base - stack_size * STACK_DIRECTION;
pthread_attr_destroy(&attr); /* Clean up */
}
else
{
/*
Fallback:
Use the current stack pointer as an approximation of the start
*/
*stack_start= my_get_stack_pointer(fallback_stack_start);
stack_size= (fallback_stack_size -
MY_MIN(fallback_stack_size, MY_STACK_SAFE_MARGIN));
}
#else
/* Platform does not have pthread_getattr_np */
*stack_start= my_get_stack_pointer(fallback_stack_start);
stack_size= (fallback_stack_size -
MY_MIN(fallback_stack_size, MY_STACK_SAFE_MARGIN));
#endif /* defined(HAVE_PTHREAD_GETATTR_NP) */
*stack_end= *stack_start + stack_size * STACK_DIRECTION;
#elif defined(_MSC_VER) && defined(_WIN32)
/* Windows platform (MSVC) */
NT_TIB* teb= (NT_TIB*)NtCurrentTeb();
*stack_start= teb->StackBase; /* Start of the stack */
*stack_end= teb->StackLimit; /* End of the stack (stack limit) */
#else
/* Unsupported platform / compiler */
*stack_start= my_get_stack_pointer(fallback_stack_start);
*stack_end= (*stack_start +
(fallback_stack_size -
MY_MIN(fallback_stack_size, MY_STACK_SAFE_MARGIN)) *
STACK_DIRECTON);
#endif /* defined(__GNUC__) || defined(__clang__) */
}

View File

@@ -141,7 +141,7 @@ int my_is_symlink(const char *filename __attribute__((unused)))
int my_realpath(char *to, const char *filename, myf MyFlags)
{
#if defined(HAVE_REALPATH) && !defined(HAVE_BROKEN_REALPATH)
#if defined(HAVE_REALPATH)
int result=0;
char buff[BUFF_LEN];
char *ptr;

View File

@@ -117,15 +117,13 @@ static bool report_unknown_option(THD *thd, engine_option_value *val,
#define value_ptr(STRUCT,OPT) ((char*)(STRUCT) + (OPT)->offset)
static bool set_one_value(ha_create_table_option *opt,
THD *thd, const LEX_CSTRING *value, void *base,
bool suppress_warning,
MEM_ROOT *root)
static bool set_one_value(ha_create_table_option *opt, THD *thd,
const LEX_CSTRING *value, void *base,
bool suppress_warning, MEM_ROOT *root)
{
DBUG_ENTER("set_one_value");
DBUG_PRINT("enter", ("opt: %p type: %u name '%s' value: '%s'",
opt,
opt->type, opt->name,
opt, opt->type, opt->name,
(value->str ? value->str : "<DEFAULT>")));
switch (opt->type)
{
@@ -141,10 +139,9 @@ static bool set_one_value(ha_create_table_option *opt,
DBUG_RETURN(0);
}
my_option optp=
{ opt->name, 1, 0, (uchar **)val, 0, 0, GET_ULL,
my_option optp= { opt->name, 1, 0, (uchar **)val, 0, 0, GET_ULL,
REQUIRED_ARG, (longlong)opt->def_value, (longlong)opt->min_value,
opt->max_value, 0, (long) opt->block_size, 0};
opt->max_value, 0, (long) opt->block_size, 0 };
ulonglong orig_val= strtoull(value->str, NULL, 10);
my_bool unused;
@@ -236,6 +233,73 @@ static bool set_one_value(ha_create_table_option *opt,
static const size_t ha_option_type_sizeof[]=
{ sizeof(ulonglong), sizeof(char *), sizeof(uint), sizeof(bool)};
/**
Appends values of sysvar-based options if needed
@param thd thread handler
@param option_list list of options given by user
@param rules list of option description by engine
@param root MEM_ROOT where allocate memory
@retval TRUE Error
@retval FALSE OK
*/
bool extend_option_list(THD* thd, handlerton *hton, bool create,
engine_option_value **option_list,
ha_create_table_option *rules)
{
DBUG_ENTER("extend_option_list");
MEM_ROOT *root= thd->mem_root;
bool extended= false;
for (ha_create_table_option *opt= rules; rules && opt->name; opt++)
{
if (opt->var)
{
engine_option_value *found= NULL, *last;
for (engine_option_value *val= *option_list; val; val= val->next)
{
last= val;
if (!system_charset_info->strnncoll(opt->name, opt->name_length,
val->name.str, val->name.length))
found= val; // find the last matching
}
if (found ? !found->value.str : create)
{
/* add the current value of the corresponding sysvar to the list */
sys_var *sysvar= find_hton_sysvar(hton, opt->var);
DBUG_ASSERT(sysvar);
if (!sysvar->session_is_default(thd))
{
StringBuffer<256> sbuf(system_charset_info);
String *str= sysvar->val_str(&sbuf, thd, OPT_SESSION, &null_clex_str);
DBUG_ASSERT(str);
LEX_CSTRING name= { opt->name, opt->name_length };
LEX_CSTRING value= safe_lexcstrdup_root(root, str->to_lex_cstring());
if (found)
found->value= value;
else
{
if (!extended)
{
if (*option_list)
thd->register_item_tree_change((Item**)&(last->next));
extended= true;
}
new (root) engine_option_value(name, value,
opt->type != HA_OPTION_TYPE_ULL, option_list, &last);
}
}
}
}
}
DBUG_RETURN(FALSE);
}
/**
Creates option structure and parses list of options in it
@@ -250,7 +314,7 @@ static const size_t ha_option_type_sizeof[]=
@retval FALSE OK
*/
bool parse_option_list(THD* thd, handlerton *hton, void *option_struct_arg,
bool parse_option_list(THD* thd, void *option_struct_arg,
engine_option_value **option_list,
ha_create_table_option *rules,
bool suppress_warning, MEM_ROOT *root)
@@ -296,59 +360,9 @@ bool parse_option_list(THD* thd, handlerton *hton, void *option_struct_arg,
break;
}
if (!seen || (opt->var && !last->value.str))
{
LEX_CSTRING default_val= null_clex_str;
/*
Okay, here's the logic for sysvar options:
1. When we parse CREATE TABLE and sysvar option was not explicitly
mentioned we add it to the list as if it was specified with the
*current* value of the underlying sysvar.
2. But only if the underlying sysvar value is different from the
sysvar's default.
3. If it's ALTER TABLE or CREATE_SEQUENCE and the sysvar option was
not explicitly mentioned - do nothing, do not add it to the list.
4. But if it was ALTER TABLE with sysvar option = DEFAULT, we
add it to the list (under the same condition #2).
5. If we're here parsing the option list from the .frm file
for a normal open_table() and the sysvar option was not there -
do not add it to the list (makes no sense anyway) and
use the *default* value of the underlying sysvar. Because
sysvar value can change, but it should not affect existing tables.
This is how it's implemented: the current sysvar value is added
to the list if suppress_warning is FALSE (meaning a table is created,
that is CREATE TABLE or ALTER TABLE) and it's actually a CREATE TABLE
command or it's an ALTER TABLE and the option was seen (=DEFAULT).
Note that if the option was set explicitly (not =DEFAULT) it wouldn't
have passes the if() condition above.
*/
if (!suppress_warning && opt->var &&
(thd->lex->sql_command == SQLCOM_CREATE_TABLE || seen))
{
// take a value from the variable and add it to the list
sys_var *sysvar= find_hton_sysvar(hton, opt->var);
DBUG_ASSERT(sysvar);
if (!sysvar->session_is_default(thd))
{
char buf[256];
String sbuf(buf, sizeof(buf), system_charset_info), *str;
if ((str= sysvar->val_str(&sbuf, thd, OPT_SESSION, &null_clex_str)))
{
LEX_CSTRING name= { opt->name, opt->name_length };
default_val.str= strmake_root(root, str->ptr(), str->length());
default_val.length= str->length();
val= new (root) engine_option_value(name, default_val,
opt->type != HA_OPTION_TYPE_ULL, option_list, &last);
val->parsed= true;
}
}
}
set_one_value(opt, thd, &default_val, *option_struct,
set_one_value(opt, thd, &null_clex_str, *option_struct,
suppress_warning, root);
}
}
for (val= *option_list; val; val= val->next)
{
@@ -474,13 +488,13 @@ bool parse_engine_table_options(THD *thd, handlerton *ht, TABLE_SHARE *share)
MEM_ROOT *root= &share->mem_root;
DBUG_ENTER("parse_engine_table_options");
if (parse_option_list(thd, ht, &share->option_struct, & share->option_list,
if (parse_option_list(thd, &share->option_struct, & share->option_list,
ht->table_options, TRUE, root))
DBUG_RETURN(TRUE);
for (Field **field= share->field; *field; field++)
{
if (parse_option_list(thd, ht, &(*field)->option_struct,
if (parse_option_list(thd, &(*field)->option_struct,
& (*field)->option_list,
ht->field_options, TRUE, root))
DBUG_RETURN(TRUE);
@@ -488,7 +502,7 @@ bool parse_engine_table_options(THD *thd, handlerton *ht, TABLE_SHARE *share)
for (uint index= 0; index < share->keys; index ++)
{
if (parse_option_list(thd, ht, &share->key_info[index].option_struct,
if (parse_option_list(thd, &share->key_info[index].option_struct,
& share->key_info[index].option_list,
ht->index_options, TRUE, root))
DBUG_RETURN(TRUE);
@@ -799,4 +813,3 @@ bool is_engine_option_known(engine_option_value *opt,
}
return false;
}

View File

@@ -83,10 +83,14 @@ class Create_field;
bool resolve_sysvar_table_options(handlerton *hton);
void free_sysvar_table_options(handlerton *hton);
bool parse_engine_table_options(THD *thd, handlerton *ht, TABLE_SHARE *share);
bool parse_option_list(THD* thd, handlerton *hton, void *option_struct,
bool parse_option_list(THD* thd, void *option_struct,
engine_option_value **option_list,
ha_create_table_option *rules,
bool suppress_warning, MEM_ROOT *root);
bool extend_option_list(THD* thd, handlerton *hton, bool create,
engine_option_value **option_list,
ha_create_table_option *rules);
bool engine_table_options_frm_read(const uchar *buff, size_t length,
TABLE_SHARE *share);
engine_option_value *merge_engine_table_options(engine_option_value *source,

View File

@@ -2727,7 +2727,6 @@ int ddl_log_execute_recovery()
DBUG_RETURN(1);
}
original_thd= current_thd; // Probably NULL
thd->thread_stack= (char*) &thd;
thd->store_globals();
thd->init(); // Needed for error messages

View File

@@ -219,12 +219,10 @@ pre_init_event_thread(THD* thd)
pthread_handler_t
event_scheduler_thread(void *arg)
{
/* needs to be first for thread_stack */
THD *thd= (THD *) ((struct scheduler_param *) arg)->thd;
Event_scheduler *scheduler= ((struct scheduler_param *) arg)->scheduler;
bool res;
thd->thread_stack= (char *)&thd; // remember where our stack is
thd->reset_stack();
mysql_thread_set_psi_id(thd->thread_id);
@@ -285,8 +283,6 @@ event_worker_thread(void *arg)
void
Event_worker_thread::run(THD *thd, Event_queue_element_for_exec *event)
{
/* needs to be first for thread_stack */
char my_stack;
Event_job_data job_data;
bool res;
@@ -302,7 +298,6 @@ Event_worker_thread::run(THD *thd, Event_queue_element_for_exec *event)
thd->charset(), NULL);
#endif
thd->thread_stack= &my_stack; // remember where our stack is
res= post_init_event_thread(thd);
DBUG_ENTER("Event_worker_thread::run");

View File

@@ -898,12 +898,6 @@ Events::init(THD *thd, bool opt_noacl_or_bootstrap)
res= TRUE;
goto end;
}
/*
The thread stack does not start from this function but we cannot
guess the real value. So better some value that doesn't assert than
no value.
*/
thd->thread_stack= (char*) &thd;
thd->store_globals();
/*
Set current time for the thread that handles events.

View File

@@ -367,6 +367,21 @@ int ha_sequence::external_lock(THD *thd, int lock_type)
return error;
}
int ha_sequence::discard_or_import_tablespace(my_bool discard)
{
int error= file->discard_or_import_tablespace(discard);
if (!error && !discard)
{
/* Doing import table space. Read the imported values */
if (!(error= table->s->sequence->read_stored_values(table)))
{
table->s->sequence->initialized= SEQUENCE::SEQ_READY_TO_USE;
memcpy(table->record[1], table->s->default_values, table->s->reclength);
}
}
return error;
}
/*
Squence engine error deal method
*/

View File

@@ -65,6 +65,8 @@ public:
ha_sequence(handlerton *hton, TABLE_SHARE *share);
~ha_sequence();
virtual handlerton *storage_ht() const override
{ return file->ht; }
/* virtual function that are re-implemented for sequence */
int open(const char *name, int mode, uint test_if_locked) override;
@@ -143,7 +145,7 @@ public:
{ file->unbind_psi(); }
void rebind_psi() override
{ file->rebind_psi(); }
int discard_or_import_tablespace(my_bool discard) override;
bool auto_repair(int error) const override
{ return file->auto_repair(error); }
int repair(THD* thd, HA_CHECK_OPT* check_opt) override

View File

@@ -5181,6 +5181,12 @@ public:
virtual handlerton *partition_ht() const
{ return ht; }
virtual bool partition_engine() { return 0;}
/*
Used with 'wrapper' engines, like SEQUENCE, to access to the
underlaying engine used for storage.
*/
virtual handlerton *storage_ht() const
{ return ht; }
inline int ha_write_tmp_row(uchar *buf);
inline int ha_delete_tmp_row(uchar *buf);
inline int ha_update_tmp_row(const uchar * old_data, uchar * new_data);

View File

@@ -7961,6 +7961,7 @@ static
Item *find_producing_item(Item *item, st_select_lex *sel)
{
DBUG_ASSERT(item->type() == Item::FIELD_ITEM ||
item->type() == Item::TRIGGER_FIELD_ITEM ||
(item->type() == Item::REF_ITEM &&
((Item_ref *) item)->ref_type() == Item_ref::VIEW_REF));
Item_field *field_item= NULL;
@@ -9745,6 +9746,7 @@ bool Item_default_value::fix_fields(THD *thd, Item **items)
void Item_default_value::cleanup()
{
if (!m_share_field)
delete field; // Free cached blob data
Item_field::cleanup();
}

View File

@@ -6906,8 +6906,9 @@ public:
class Item_default_value : public Item_field
{
bool vcol_assignment_ok;
bool m_associated= false;
bool vcol_assignment_ok:1;
bool m_associated:1;
bool m_share_field:1;
void calculate();
public:
@@ -6915,7 +6916,11 @@ public:
Item_default_value(THD *thd, Name_resolution_context *context_arg, Item *a,
bool vcol_assignment_arg)
: Item_field(thd, context_arg),
vcol_assignment_ok(vcol_assignment_arg), arg(a) {}
vcol_assignment_ok(vcol_assignment_arg), arg(a)
{
m_associated= false;
m_share_field= false;
}
Type type() const override { return DEFAULT_VALUE_ITEM; }
bool eq(const Item *item, bool binary_cmp) const override;
bool fix_fields(THD *, Item **) override;
@@ -6975,6 +6980,10 @@ public:
}
Item *transform(THD *thd, Item_transformer transformer, uchar *args)
override;
Item *derived_field_transformer_for_having(THD *thd, uchar *arg) override
{ return NULL; }
Item *derived_field_transformer_for_where(THD *thd, uchar *arg) override
{ return NULL; }
Field *create_tmp_field_ex(MEM_ROOT *root, TABLE *table, Tmp_field_src *src,
const Tmp_field_param *param) override;
@@ -6984,7 +6993,13 @@ public:
*/
bool associate_with_target_field(THD *thd, Item_field *field) override;
Item *do_get_copy(THD *thd) const override
{ return get_item_copy<Item_default_value>(thd, this); }
{
Item_default_value *new_item=
(Item_default_value *) get_item_copy<Item_default_value>(thd, this);
// This is a copy so do not manage the field and should not delete it
new_item->m_share_field= 1;
return new_item;
}
Item* do_build_clone(THD *thd) const override { return get_copy(thd); }
private:
bool tie_field(THD *thd);
@@ -7230,6 +7245,9 @@ Item_trigger_field(THD *thd, Name_resolution_context *context_arg,
Item *copy_or_same(THD *) override { return this; }
Item *get_tmp_table_item(THD *thd) override { return copy_or_same(thd); }
void cleanup() override;
Item *do_get_copy(THD *thd) const override
{ return get_item_copy<Item_trigger_field>(thd, this); }
Item *do_build_clone(THD *thd) const override { return get_copy(thd); }
private:
void set_required_privilege(bool rw) override;

View File

@@ -10650,7 +10650,6 @@ binlog_background_thread(void *arg __attribute__((unused)))
thd= new THD(next_thread_id());
thd->system_thread= SYSTEM_THREAD_BINLOG_BACKGROUND;
thd->thread_stack= (char*) &thd; /* Set approximate stack start */
thd->store_globals();
thd->security_ctx->skip_grants();
thd->set_command(COM_DAEMON);

View File

@@ -5550,6 +5550,26 @@ static void test_lc_time_sz()
#endif//DBUG_OFF
static void run_main_loop()
{
select_thread=pthread_self();
mysql_mutex_lock(&LOCK_start_thread);
select_thread_in_use=1;
mysql_mutex_unlock(&LOCK_start_thread);
#ifdef _WIN32
handle_connections_win();
#else
handle_connections_sockets();
mysql_mutex_lock(&LOCK_start_thread);
select_thread_in_use=0;
mysql_cond_broadcast(&COND_start_thread);
mysql_mutex_unlock(&LOCK_start_thread);
#endif /* _WIN32 */
}
int mysqld_main(int argc, char **argv)
{
#ifndef _WIN32
@@ -5740,9 +5760,6 @@ int mysqld_main(int argc, char **argv)
SYSVAR_AUTOSIZE(my_thread_stack_size, new_thread_stack_size);
}
select_thread=pthread_self();
select_thread_in_use=1;
#ifdef HAVE_LIBWRAP
libwrapName= my_progname+dirname_length(my_progname);
openlog(libwrapName, LOG_PID, LOG_AUTH);
@@ -5796,7 +5813,6 @@ int mysqld_main(int argc, char **argv)
// Recover and exit.
if (wsrep_recovery)
{
select_thread_in_use= 0;
if (WSREP_ON)
wsrep_recover();
else
@@ -5869,7 +5885,6 @@ int mysqld_main(int argc, char **argv)
if (opt_bootstrap)
{
select_thread_in_use= 0; // Allow 'kill' to work
int bootstrap_error= bootstrap(mysql_stdin);
if (!abort_loop)
unireg_abort(bootstrap_error);
@@ -5909,12 +5924,11 @@ int mysqld_main(int argc, char **argv)
mysqld_port, MYSQL_COMPILATION_COMMENT);
else
{
char real_server_version[2 * SERVER_VERSION_LENGTH + 10];
char real_server_version[2 * SERVER_VERSION_LENGTH + 10], *pos;
set_server_version(real_server_version, sizeof(real_server_version));
safe_strcat(real_server_version, sizeof(real_server_version), "' as '");
safe_strcat(real_server_version, sizeof(real_server_version),
server_version);
pos= set_server_version(real_server_version, sizeof(real_server_version)-1);
strxnmov(pos, sizeof(real_server_version) - 1 - (pos-real_server_version),
"' as '", server_version, NullS);
sql_print_information(ER_DEFAULT(ER_STARTUP), my_progname,
real_server_version,
@@ -5944,16 +5958,7 @@ int mysqld_main(int argc, char **argv)
/* Memory used when everything is setup */
start_memory_used= global_status_var.global_memory_used;
#ifdef _WIN32
handle_connections_win();
#else
handle_connections_sockets();
mysql_mutex_lock(&LOCK_start_thread);
select_thread_in_use=0;
mysql_cond_broadcast(&COND_start_thread);
mysql_mutex_unlock(&LOCK_start_thread);
#endif /* _WIN32 */
run_main_loop();
/* Shutdown requested */
char *user= shutdown_user.load(std::memory_order_relaxed);
@@ -7723,7 +7728,7 @@ static int mysql_init_variables(void)
/* Things reset to zero */
opt_skip_slave_start= opt_reckless_slave = 0;
mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0;
#if defined(HAVE_REALPATH) && !defined(HAVE_valgrind) && !defined(HAVE_BROKEN_REALPATH)
#if defined(HAVE_REALPATH) && !defined(HAVE_valgrind)
/* We can only test for sub paths if my_symlink.c is using realpath */
mysys_test_invalid_symlink= path_starts_from_data_home_dir;
#endif
@@ -7823,6 +7828,8 @@ static int mysql_init_variables(void)
lc_messages= (char*) "en_US";
lc_time_names_name= (char*) "en_US";
have_symlink= SHOW_OPTION_YES;
/* Variables that depends on compile options */
#ifndef DBUG_OFF
default_dbug_option=IF_WIN("d:t:i:O,\\mariadbd.trace",
@@ -7846,11 +7853,6 @@ static int mysql_init_variables(void)
#else
have_openssl= have_ssl= SHOW_OPTION_NO;
#endif
#ifdef HAVE_BROKEN_REALPATH
have_symlink=SHOW_OPTION_NO;
#else
have_symlink=SHOW_OPTION_YES;
#endif
#ifdef HAVE_DLOPEN
have_dlopen=SHOW_OPTION_YES;
#else
@@ -8641,7 +8643,7 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
global_system_variables.sql_mode=
expand_sql_mode(global_system_variables.sql_mode);
#if !defined(HAVE_REALPATH) || defined(HAVE_BROKEN_REALPATH)
#if !defined(HAVE_REALPATH)
my_use_symdir=0;
my_disable_symlinks=1;
have_symlink=SHOW_OPTION_NO;
@@ -8777,7 +8779,7 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
(MYSQL_SERVER_SUFFIX is set by the compilation environment)
*/
void set_server_version(char *buf, size_t size)
char *set_server_version(char *buf, size_t size)
{
bool is_log= opt_log || global_system_variables.sql_log_slow || opt_bin_log;
bool is_debug= IF_DBUG(!strstr(MYSQL_SERVER_SUFFIX_STR, "-debug"), 0);
@@ -8786,7 +8788,7 @@ void set_server_version(char *buf, size_t size)
!strstr(MYSQL_SERVER_SUFFIX_STR, "-valgrind") ? "-valgrind" :
#endif
"";
strxnmov(buf, size - 1,
return strxnmov(buf, size - 1,
MYSQL_SERVER_VERSION,
MYSQL_SERVER_SUFFIX_STR,
IF_EMBEDDED("-embedded", ""),

View File

@@ -937,7 +937,7 @@ inline void table_case_convert(char * name, uint length)
files_charset_info->casedn(name, length, name, length);
}
extern void set_server_version(char *buf, size_t size);
extern char *set_server_version(char *buf, size_t size);
#define current_thd _current_thd()
void set_current_thd(THD *thd);

View File

@@ -2764,7 +2764,8 @@ bool find_eq_ref_candidate(TABLE *table, table_map sj_inner_tables)
keyuse++;
} while (keyuse->key == key && keyuse->table == table);
if (bound_parts == PREV_BITS(uint, keyinfo->user_defined_key_parts))
if (bound_parts == PREV_BITS(key_part_map,
keyinfo->user_defined_key_parts))
return TRUE;
}
else

View File

@@ -1112,7 +1112,6 @@ bool Master_info_index::init_all_master_info()
}
thd= new THD(next_thread_id()); /* Needed by start_slave_threads */
thd->thread_stack= (char*) &thd;
thd->store_globals();
reinit_io_cache(&index_file, READ_CACHE, 0L,0,0);

View File

@@ -1197,7 +1197,6 @@ handle_rpl_parallel_thread(void *arg)
my_thread_init();
thd = new THD(next_thread_id());
thd->thread_stack = (char*)&thd;
server_threads.insert(thd);
set_current_thd(thd);
pthread_detach_this_thread();

View File

@@ -251,7 +251,6 @@ void Ack_receiver::run()
sql_print_information("Starting ack receiver thread");
thd->system_thread= SYSTEM_THREAD_SEMISYNC_MASTER_BACKGROUND;
thd->thread_stack= (char*) &thd;
thd->store_globals();
thd->security_ctx->skip_grants();
thd->set_command(COM_DAEMON);

View File

@@ -7648,6 +7648,7 @@ ER_ACCESS_DENIED_NO_PASSWORD_ERROR 28000
ukr "Доступ заборонено для користувача: '%s'@'%s'"
ER_SET_PASSWORD_AUTH_PLUGIN
chi "SET PASSWORD不适用于通过%s插件验证的用户"
eng "SET PASSWORD is not applicable for users authenticating via %s plugin"
ukr "SET PASSWORD не можна застосувати для користувачів, що автентифікуються з допомогою плагінy %s"

View File

@@ -368,7 +368,6 @@ end:
static THD *new_bg_THD()
{
THD *thd= new THD(next_thread_id());
thd->thread_stack= (char*) &thd;
thd->store_globals();
thd->system_thread = SYSTEM_THREAD_SLAVE_BACKGROUND;
thd->security_ctx->skip_grants();
@@ -629,7 +628,6 @@ int init_slave()
{
int error;
THD *thd= new THD(next_thread_id());
thd->thread_stack= (char*) &thd;
thd->store_globals();
error= start_slave_threads(0, /* No active thd */
@@ -4767,7 +4765,12 @@ pthread_handler_t handle_slave_io(void *arg)
thd->set_psi(PSI_CALL_get_thread());
pthread_detach_this_thread();
thd->thread_stack= (char*) &thd; // remember where our stack is
/*
Remember where our stack is. This is needed for this function as
there are a lot of stack variables. It will be fixed in store_globals()
called by init_slave_thread().
*/
thd->thread_stack= (void*) &thd; // remember where our stack is
mi->clear_error();
if (init_slave_thread(thd, mi, SLAVE_THD_IO))
{
@@ -5412,7 +5415,7 @@ pthread_handler_t handle_slave_sql(void *arg)
serial_rgi= new rpl_group_info(rli);
thd = new THD(next_thread_id()); // note that contructor of THD uses DBUG_ !
thd->thread_stack = (char*)&thd; // remember where our stack is
thd->thread_stack= (void*) &thd; // Big stack, remember where our stack is
thd->system_thread_info.rpl_sql_info= &sql_info;
DBUG_ASSERT(rli->inited);

View File

@@ -2531,7 +2531,6 @@ bool acl_init(bool dont_read_acl_tables)
*/
if (!(thd=new THD(0)))
DBUG_RETURN(1); /* purecov: inspected */
thd->thread_stack= (char*) &thd;
thd->store_globals();
/*
It is safe to call acl_reload() since acl_* arrays and hashes which
@@ -7966,7 +7965,6 @@ bool grant_init()
if (!(thd= new THD(0)))
DBUG_RETURN(1); /* purecov: deadcode */
thd->thread_stack= (char*) &thd;
thd->store_globals();
return_val= grant_reload(thd);
delete thd;

View File

@@ -9091,17 +9091,17 @@ fill_record_n_invoke_before_triggers(THD *thd, TABLE *table, Field **ptr,
my_bool mysql_rm_tmp_tables(void)
{
THD *thd;
uint i, idx;
char path[FN_REFLEN], *tmpdir, path_copy[FN_REFLEN];
MY_DIR *dirp;
FILEINFO *file;
TABLE_SHARE share;
THD *thd;
DBUG_ENTER("mysql_rm_tmp_tables");
if (!(thd= new THD(0)))
DBUG_RETURN(1);
thd->thread_stack= (char*) &thd;
thd->thread_stack= (void*) &thd; // Big stack
thd->store_globals();
for (i=0; i<=mysql_tmpdir_list.max; i++)

View File

@@ -2246,12 +2246,6 @@ void THD::reset_killed()
void THD::store_globals()
{
/*
Assert that thread_stack is initialized: it's necessary to be able
to track stack overrun.
*/
DBUG_ASSERT(thread_stack);
set_current_thd(this);
/*
mysys_var is concurrently readable by a killer thread.
@@ -2283,8 +2277,11 @@ void THD::store_globals()
os_thread_id= 0;
#endif
real_id= pthread_self(); // For debugging
mysys_var->stack_ends_here= thread_stack + // for consistency, see libevent_thread_proc
STACK_DIRECTION * (long)my_thread_stack_size;
/* Set stack start and stack end */
my_get_stack_bounds(&thread_stack, &mysys_var->stack_ends_here,
thread_stack, my_thread_stack_size);
if (net.vio)
{
net.thd= this;
@@ -2296,6 +2293,7 @@ void THD::store_globals()
thr_lock_info_init(&lock_info, mysys_var);
}
/**
Untie THD from current thread
@@ -5065,7 +5063,6 @@ TABLE *find_fk_open_table(THD *thd, const char *db, size_t db_len,
MYSQL_THD create_thd()
{
THD *thd= new THD(next_thread_id());
thd->thread_stack= (char*) &thd;
thd->store_globals();
thd->set_command(COM_DAEMON);
thd->system_thread= SYSTEM_THREAD_GENERIC;
@@ -5145,7 +5142,6 @@ void *thd_attach_thd(MYSQL_THD thd)
auto save_mysysvar= pthread_getspecific(THR_KEY_mysys);
pthread_setspecific(THR_KEY_mysys, thd->mysys_var);
thd->thread_stack= (char *) &thd;
thd->store_globals();
return save_mysysvar;
}

View File

@@ -2826,7 +2826,7 @@ public:
A pointer to the stack frame of handle_one_connection(),
which is called first in the thread for handling a client
*/
char *thread_stack;
void *thread_stack;
/**
Currently selected catalog.
@@ -3915,6 +3915,10 @@ public:
void free_connection();
void reset_for_reuse();
void store_globals();
void reset_stack()
{
thread_stack= 0;
}
void reset_globals();
bool trace_started()
{
@@ -4616,14 +4620,19 @@ public:
return !stmt_arena->is_conventional();
}
void register_item_tree_change(Item **place)
{
/* TODO: check for OOM condition here */
if (is_item_tree_change_register_required())
nocheck_register_item_tree_change(place, *place, mem_root);
}
void change_item_tree(Item **place, Item *new_value)
{
DBUG_ENTER("THD::change_item_tree");
DBUG_PRINT("enter", ("Register: %p (%p) <- %p",
*place, place, new_value));
/* TODO: check for OOM condition here */
if (is_item_tree_change_register_required())
nocheck_register_item_tree_change(place, *place, mem_root);
register_item_tree_change(place);
*place= new_value;
DBUG_VOID_RETURN;
}

View File

@@ -1387,16 +1387,6 @@ void do_handle_one_connection(CONNECT *connect, bool put_in_cache)
thd->thr_create_utime= thr_create_utime;
/* We need to set this because of time_out_user_resource_limits */
thd->start_utime= thr_create_utime;
/*
handle_one_connection() is normally the only way a thread would
start and would always be on the very high end of the stack ,
therefore, the thread stack always starts at the address of the
first local variable of handle_one_connection, which is thd. We
need to know the start of the stack so that we could check for
stack overruns.
*/
thd->thread_stack= (char*) &thd;
setup_connection_thread_globals(thd);
for (;;)

View File

@@ -398,9 +398,10 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
if (returning)
(void) result->prepare(returning->item_list, NULL);
if (thd->lex->current_select->first_cond_optimization)
if (!thd->lex->current_select->leaf_tables_saved)
{
thd->lex->current_select->save_leaf_tables(thd);
thd->lex->current_select->leaf_tables_saved= true;
thd->lex->current_select->first_cond_optimization= 0;
}
/* check ORDER BY even if it can be ignored */
@@ -523,6 +524,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
{
thd->lex->current_select->save_leaf_tables(thd);
thd->lex->current_select->leaf_tables_saved= true;
thd->lex->current_select->first_cond_optimization= 0;
}
my_ok(thd, 0);
@@ -561,6 +563,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
{
thd->lex->current_select->save_leaf_tables(thd);
thd->lex->current_select->leaf_tables_saved= true;
thd->lex->current_select->first_cond_optimization= 0;
}
my_ok(thd, 0);
@@ -941,6 +944,7 @@ cleanup:
{
thd->lex->current_select->save_leaf_tables(thd);
thd->lex->current_select->leaf_tables_saved= true;
thd->lex->current_select->first_cond_optimization= 0;
}
delete deltempfile;

View File

@@ -3234,7 +3234,6 @@ pthread_handler_t handle_delayed_insert(void *arg)
else
{
DBUG_ENTER("handle_delayed_insert");
thd->thread_stack= (char*) &thd;
if (init_thr_lock())
{
thd->get_stmt_da()->set_error_status(ER_OUT_OF_RESOURCES);

View File

@@ -3662,7 +3662,7 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)
return false;
Item **array= static_cast<Item**>(
thd->active_stmt_arena_to_use()->alloc(sizeof(Item*) * n_elems));
thd->active_stmt_arena_to_use()->calloc(sizeof(Item*) * n_elems));
if (likely(array != NULL))
ref_pointer_array= Ref_ptr_array(array, n_elems);
return array == NULL;

View File

@@ -247,7 +247,7 @@ public:
String &field_term,String &line_start,String &line_term,
String &enclosed,int escape,bool get_it_from_net, bool is_fifo);
~READ_INFO();
int read_field();
int read_field(CHARSET_INFO *cs);
int read_fixed_length(void);
int next_line(void);
char unescape(char chr);
@@ -1134,7 +1134,15 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
{
uint length;
uchar *pos;
if (read_info.read_field())
CHARSET_INFO *cs;
/*
Avoiding of handling binary data as a text
*/
if(item->charset_for_protocol() == &my_charset_bin)
cs= &my_charset_bin;
else
cs= read_info.charset();
if (read_info.read_field(cs))
break;
/* If this line is to be skipped we don't want to fill field or var */
@@ -1507,7 +1515,7 @@ inline bool READ_INFO::terminator(const uchar *ptr, uint length)
must make sure to use escapes properly.
*/
int READ_INFO::read_field()
int READ_INFO::read_field(CHARSET_INFO *cs)
{
int chr,found_enclosed_char;
@@ -1543,7 +1551,7 @@ int READ_INFO::read_field()
for (;;)
{
// Make sure we have enough space for the longest multi-byte character.
while (data.length() + charset()->mbmaxlen <= data.alloced_length())
while (data.length() + cs->mbmaxlen <= data.alloced_length())
{
chr = GET;
if (chr == my_b_EOF)
@@ -1629,7 +1637,7 @@ int READ_INFO::read_field()
}
}
data.append(chr);
if (charset()->use_mb() && read_mbtail(&data))
if (cs->use_mb() && read_mbtail(&data))
goto found_eof;
}
/*

View File

@@ -1004,7 +1004,6 @@ int bootstrap(MYSQL_FILE *file)
#endif
/* The following must be called before DBUG_ENTER */
thd->thread_stack= (char*) &thd;
thd->store_globals();
thd->security_ctx->user= (char*) my_strdup(key_memory_MPVIO_EXT_auth_info,
@@ -7600,7 +7599,9 @@ check_stack_overrun(THD *thd, long margin, uchar *buf __attribute__((unused)))
#ifndef __SANITIZE_ADDRESS__
long stack_used;
DBUG_ASSERT(thd == current_thd);
if ((stack_used= available_stack_size(thd->thread_stack, &stack_used)) >=
DBUG_ASSERT(thd->thread_stack);
if ((stack_used= available_stack_size(thd->thread_stack,
my_get_stack_pointer(&stack_used))) >=
(long) (my_thread_stack_size - margin))
{
thd->is_fatal_error= 1;

View File

@@ -1892,7 +1892,7 @@ static void plugin_load(MEM_ROOT *tmp_root)
if (global_system_variables.log_warnings >= 9)
sql_print_information("Initializing installed plugins");
new_thd->thread_stack= (char*) &tables;
new_thd->thread_stack= (void*) &tables; // Big stack
new_thd->store_globals();
new_thd->db= MYSQL_SCHEMA_NAME;
bzero((char*) &new_thd->net, sizeof(new_thd->net));

View File

@@ -6290,7 +6290,7 @@ loc_advanced_command(MYSQL *mysql, enum enum_server_command command,
{
THD *thd_orig= current_thd;
set_current_thd(p->thd);
p->thd->thread_stack= (char*) &result;
p->thd->thread_stack= (void*) &result; // Big stack
p->thd->set_time();
result= execute_server_code(p->thd, (const char *)arg, arg_length);
p->thd->cleanup_after_query();
@@ -6470,7 +6470,6 @@ extern "C" MYSQL *mysql_real_connect_local(MYSQL *mysql)
new_thd= new THD(0);
local_connection_thread_count++;
new_thd->thread_stack= (char*) &thd_orig;
new_thd->store_globals();
new_thd->security_ctx->skip_grants();
new_thd->query_cache_is_applicable= 0;

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