Merge tag 'mariadb-5.5.54' into 5.5-galera

This commit is contained in:
Nirbhay Choubey 2016-12-27 21:39:05 -05:00
commit 901f7ebcf3
127 changed files with 1998 additions and 583 deletions

1
.gitignore vendored
View file

@ -49,6 +49,7 @@ extra/jemalloc/build/
extra/jemalloc/tmp/
extra/my_print_defaults
extra/mysql_waitpid
extra/mysqld_safe_helper
extra/perror
extra/replace
extra/resolve_stack_dump

View file

@ -1,4 +1,4 @@
MYSQL_VERSION_MAJOR=5
MYSQL_VERSION_MINOR=5
MYSQL_VERSION_PATCH=53
MYSQL_VERSION_PATCH=54
MYSQL_VERSION_EXTRA=

View file

@ -1516,8 +1516,10 @@ static my_bool get_pidfile(MYSQL *mysql, char *pidfile)
if (mysql_query(mysql, "SHOW VARIABLES LIKE 'pid_file'"))
{
my_printf_error(0, "query failed; error: '%s'", error_flags,
mysql_error(mysql));
my_printf_error(mysql_errno(mysql),
"The query to get the server's pid file failed,"
" error: '%s'. Continuing.", error_flags,
mysql_error(mysql));
}
result = mysql_store_result(mysql);
if (result)

View file

@ -1705,11 +1705,11 @@ int cat_file(DYNAMIC_STRING* ds, const char* filename)
while((len= my_read(fd, (uchar*)&buff,
sizeof(buff)-1, MYF(0))) > 0)
{
char *p= buff, *start= buff;
while (p < buff+len)
char *p= buff, *start= buff,*end=buff+len;
while (p < end)
{
/* Convert cr/lf to lf */
if (*p == '\r' && *(p+1) && *(p+1)== '\n')
if (*p == '\r' && p+1 < end && *(p+1)== '\n')
{
/* Add fake newline instead of cr and output the line */
*p= '\n';
@ -3367,16 +3367,32 @@ void do_exec(struct st_command *command)
ds_result= &ds_sorted;
}
#ifdef _WIN32
/* Workaround for CRT bug, MDEV-9409 */
_setmode(fileno(res_file), O_BINARY);
#endif
while (fgets(buf, sizeof(buf), res_file))
{
int len = (int)strlen(buf);
#ifdef _WIN32
/* Strip '\r' off newlines. */
if (len > 1 && buf[len-2] == '\r' && buf[len-1] == '\n')
{
buf[len-2] = '\n';
buf[len-1] = 0;
len--;
}
#endif
if (disable_result_log)
{
buf[strlen(buf)-1]=0;
if (len)
buf[len-1] = 0;
DBUG_PRINT("exec_result",("%s", buf));
}
else
{
replace_dynstr_append(ds_result, buf);
replace_dynstr_append_mem(ds_result, buf, len);
}
}
error= pclose(res_file);
@ -5200,7 +5216,7 @@ typedef struct
static st_error global_error_names[] =
{
{ "<No error>", -1U, "" },
{ "<No error>", ~0U, "" },
#include <mysqld_ername.h>
{ 0, 0, 0 }
};

View file

@ -231,6 +231,7 @@ IF(WIN32)
FIND_PROGRAM(SIGNTOOL_EXECUTABLE signtool
PATHS "$ENV{ProgramFiles}/Microsoft SDKs/Windows/v7.0A/bin"
"$ENV{ProgramFiles}/Windows Kits/8.0/bin/x86"
"$ENV{ProgramFiles}/Windows Kits/8.1/bin/x86"
)
IF(NOT SIGNTOOL_EXECUTABLE)
MESSAGE(FATAL_ERROR

View file

@ -120,7 +120,7 @@ IF(MSVC)
#TODO: update the code and remove the disabled warnings
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4800 /wd4805 /wd4996")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800 /wd4805 /wd4996 /wd4291 /we4099")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800 /wd4805 /wd4996 /wd4291 /wd4577 /we4099")
IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
# _WIN64 is defined by the compiler itself.

View file

@ -230,5 +230,6 @@ MACRO (MYSQL_CHECK_READLINE)
SET(CMAKE_REQUIRED_LIBRARIES)
SET(CMAKE_REQUIRED_INCLUDES)
ENDIF(NOT WIN32)
CHECK_INCLUDE_FILES ("curses.h;term.h" HAVE_TERM_H)
ENDMACRO()

View file

@ -237,7 +237,6 @@ CHECK_INCLUDE_FILES (sys/socket.h HAVE_SYS_SOCKET_H)
CHECK_INCLUDE_FILES (sys/stat.h HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILES (sys/stream.h HAVE_SYS_STREAM_H)
CHECK_INCLUDE_FILES (sys/termcap.h HAVE_SYS_TERMCAP_H)
CHECK_INCLUDE_FILES ("curses.h;term.h" HAVE_TERM_H)
CHECK_INCLUDE_FILES (asm/termbits.h HAVE_ASM_TERMBITS_H)
CHECK_INCLUDE_FILES (termbits.h HAVE_TERMBITS_H)
CHECK_INCLUDE_FILES (termios.h HAVE_TERMIOS_H)

View file

@ -33,6 +33,7 @@ usr/bin/mysql_zap
usr/bin/mysqlbinlog
usr/bin/mysqld_multi
usr/bin/mysqld_safe
usr/bin/mysqld_safe_helper
usr/bin/mysqlhotcopy
usr/bin/perror
usr/bin/replace

View file

@ -35,6 +35,7 @@ usr/bin/mysql_zap
usr/bin/mysqlbinlog
usr/bin/mysqld_multi
usr/bin/mysqld_safe
usr/bin/mysqld_safe_helper
usr/bin/mysqlhotcopy
usr/bin/perror
usr/bin/replace

View file

@ -82,4 +82,7 @@ IF(UNIX)
MYSQL_ADD_EXECUTABLE(mysql_waitpid mysql_waitpid.c COMPONENT Client)
TARGET_LINK_LIBRARIES(mysql_waitpid mysys)
MYSQL_ADD_EXECUTABLE(mysqld_safe_helper mysqld_safe_helper.c COMPONENT Server)
TARGET_LINK_LIBRARIES(mysqld_safe_helper mysys)
ENDIF()

View file

@ -0,0 +1,77 @@
#include <my_global.h>
#include <m_string.h>
#include <my_sys.h>
#include <my_pthread.h>
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#include <stdlib.h>
#include <stdio.h>
void my_exit(int c)
{
my_end(0);
exit(c);
}
void do_usage()
{
printf("Usage:\n"
" %s <user> log <filename>\n"
" %s <user> exec <command> <args>\n",
my_progname, my_progname);
my_exit(1);
}
void do_log(const char *logfile)
{
FILE *f;
uchar buf[4096];
int size;
if (!logfile)
do_usage();
f= my_fopen(logfile, O_WRONLY|O_APPEND|O_CREAT, MYF(MY_WME));
if (!f)
my_exit(1);
while ((size= my_fread(stdin, buf, sizeof(buf), MYF(MY_WME))) > 0)
if ((int)my_fwrite(f, buf, size, MYF(MY_WME)) != size)
my_exit(1);
my_fclose(f, MYF(0));
my_exit(0);
}
void do_exec(char *args[])
{
if (!args[0])
do_usage();
my_end(0);
execvp(args[0], args);
}
int main(int argc, char *argv[])
{
struct passwd *user_info;
MY_INIT(argv[0]);
if (argc < 3)
do_usage(argv[0]);
user_info= my_check_user(argv[1], MYF(0));
if (user_info ? my_set_user(argv[1], user_info, MYF(MY_WME))
: my_errno == EINVAL)
my_exit(1);
if (strcmp(argv[2], "log") == 0)
do_log(argv[3]);
if (strcmp(argv[2], "exec") == 0)
do_exec(argv+3);
my_end(0);
return 1;
}

View file

@ -602,8 +602,12 @@ extern void *my_memmem(const void *haystack, size_t haystacklen,
#ifdef _WIN32
extern int my_access(const char *path, int amode);
#define my_check_user(A,B) (NULL)
#define my_set_user(A,B,C) (0)
#else
#define my_access access
struct passwd *my_check_user(const char *user, myf MyFlags);
int my_set_user(const char *user, struct passwd *user_info, myf MyFlags);
#endif
extern int check_if_legal_filename(const char *path);

View file

@ -1743,6 +1743,11 @@ DROP TABLE t1;
--echo # Bug #31384 DATE_ADD() and DATE_SUB() return binary data
--echo #
SELECT @@collation_connection, @@character_set_results;
SELECT
CHARSET(DATE_SUB('2007-08-03', INTERVAL 1 MINUTE)) AS field_str1,
CHARSET(DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE)) AS field_str2,
CHARSET(DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY)) AS field_date,
CHARSET(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS field_datetime;
CREATE TABLE t1 AS
SELECT
DATE_SUB('2007-08-03', INTERVAL 1 MINUTE) AS field_str1,
@ -1766,7 +1771,26 @@ SELECT
HEX(DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE)) AS field1_str2,
HEX(DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY)) AS field_date,
HEX(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS field_datetime;
--echo #
--echo # MDEV-4841 Wrong character set of ADDTIME() and DATE_ADD()
--echo #
SELECT @@collation_connection, @@character_set_results;
SELECT
CHARSET(ADDTIME(_latin1'10:01:01',_latin1'10:00:00')) AS addtime1,
CHARSET(ADDTIME('10:01:01','10:00:00')) AS addtime2,
CHARSET(DATE_ADD(_latin1'2001-01-01 10:01:01',interval 10 second)) AS date_add1,
CHARSET(DATE_ADD('2001-01-01 10:01:01',interval 10 second)) AS date_add2;
CREATE TABLE t1 AS
SELECT
ADDTIME(_latin1'10:01:01',_latin1'10:00:00') AS addtime1,
ADDTIME('10:01:01','10:00:00') AS addtime2,
DATE_ADD(_latin1'2001-01-01 10:01:01',interval 10 second) AS date_add1,
DATE_ADD('2001-01-01 10:01:01',interval 10 second) AS date_add2;
SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
--echo #
--echo # Bug#11926811 / Bug#60625 Illegal mix of collations
--echo #

View file

@ -7,6 +7,7 @@ a
2002-03-04
Warnings:
Note 1003 2000-01-01
Note 1003 2000-01-06
set debug_dbug='';
drop table t1;
create table t1 (id int not null, ut timestamp(6) not null);

View file

@ -2498,4 +2498,11 @@ end|
create table t1 as select f1();
ERROR 42S02: Table 'test.t1' doesn't exist
drop function f1;
#
# MDEV-10274 Bundling insert with create statement
# for table with unsigned Decimal primary key issues warning 1194
#
create table t1(ID decimal(2,1) unsigned NOT NULL, PRIMARY KEY (ID))engine=memory
select 2.1 ID;
drop table t1;
End of 5.5 tests

View file

@ -2777,6 +2777,13 @@ DROP TABLE t1;
SELECT @@collation_connection, @@character_set_results;
@@collation_connection @@character_set_results
binary binary
SELECT
CHARSET(DATE_SUB('2007-08-03', INTERVAL 1 MINUTE)) AS field_str1,
CHARSET(DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE)) AS field_str2,
CHARSET(DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY)) AS field_date,
CHARSET(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS field_datetime;
field_str1 field_str2 field_date field_datetime
binary binary binary binary
CREATE TABLE t1 AS
SELECT
DATE_SUB('2007-08-03', INTERVAL 1 MINUTE) AS field_str1,
@ -2786,8 +2793,8 @@ DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_da
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`field_str1` varchar(19) DEFAULT NULL,
`field1_str2` varchar(19) DEFAULT NULL,
`field_str1` varbinary(19) DEFAULT NULL,
`field1_str2` varbinary(19) DEFAULT NULL,
`field_date` date DEFAULT NULL,
`field_datetime` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
@ -2812,6 +2819,37 @@ HEX(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS fie
field_str1 field1_str2 field_date field_datetime
323030372D30382D30322032333A35393A3030 323030372D30382D30332031373A33323A3030 323030372D30382D3032 323030372D30382D30332031373A33323A3030
#
# MDEV-4841 Wrong character set of ADDTIME() and DATE_ADD()
#
SELECT @@collation_connection, @@character_set_results;
@@collation_connection @@character_set_results
binary binary
SELECT
CHARSET(ADDTIME(_latin1'10:01:01',_latin1'10:00:00')) AS addtime1,
CHARSET(ADDTIME('10:01:01','10:00:00')) AS addtime2,
CHARSET(DATE_ADD(_latin1'2001-01-01 10:01:01',interval 10 second)) AS date_add1,
CHARSET(DATE_ADD('2001-01-01 10:01:01',interval 10 second)) AS date_add2;
addtime1 addtime2 date_add1 date_add2
binary binary binary binary
CREATE TABLE t1 AS
SELECT
ADDTIME(_latin1'10:01:01',_latin1'10:00:00') AS addtime1,
ADDTIME('10:01:01','10:00:00') AS addtime2,
DATE_ADD(_latin1'2001-01-01 10:01:01',interval 10 second) AS date_add1,
DATE_ADD('2001-01-01 10:01:01',interval 10 second) AS date_add2;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`addtime1` varbinary(26) DEFAULT NULL,
`addtime2` varbinary(26) DEFAULT NULL,
`date_add1` varbinary(19) DEFAULT NULL,
`date_add2` varbinary(19) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t1;
addtime1 addtime2 date_add1 date_add2
20:01:01 20:01:01 2001-01-01 10:01:11 2001-01-01 10:01:11
DROP TABLE t1;
#
# Bug#11926811 / Bug#60625 Illegal mix of collations
#
SELECT @@collation_connection;

View file

@ -3169,6 +3169,13 @@ DROP TABLE t1;
SELECT @@collation_connection, @@character_set_results;
@@collation_connection @@character_set_results
cp1251_general_ci cp1251
SELECT
CHARSET(DATE_SUB('2007-08-03', INTERVAL 1 MINUTE)) AS field_str1,
CHARSET(DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE)) AS field_str2,
CHARSET(DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY)) AS field_date,
CHARSET(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS field_datetime;
field_str1 field_str2 field_date field_datetime
cp1251 cp1251 binary binary
CREATE TABLE t1 AS
SELECT
DATE_SUB('2007-08-03', INTERVAL 1 MINUTE) AS field_str1,
@ -3178,8 +3185,8 @@ DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_da
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`field_str1` varchar(19) DEFAULT NULL,
`field1_str2` varchar(19) DEFAULT NULL,
`field_str1` varchar(19) CHARACTER SET cp1251 DEFAULT NULL,
`field1_str2` varchar(19) CHARACTER SET cp1251 DEFAULT NULL,
`field_date` date DEFAULT NULL,
`field_datetime` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
@ -3190,8 +3197,8 @@ DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def field_str1 254 19 10 Y 128 0 63
def field1_str2 254 19 19 Y 128 0 63
def field_str1 254 19 10 Y 0 0 51
def field1_str2 254 19 19 Y 0 0 51
def field_date 10 10 10 Y 128 0 63
def field_datetime 12 19 19 Y 128 0 63
field_str1 field1_str2 field_date field_datetime
@ -3204,6 +3211,37 @@ HEX(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS fie
field_str1 field1_str2 field_date field_datetime
323030372D30382D30322032333A35393A3030 323030372D30382D30332031373A33323A3030 323030372D30382D3032 323030372D30382D30332031373A33323A3030
#
# MDEV-4841 Wrong character set of ADDTIME() and DATE_ADD()
#
SELECT @@collation_connection, @@character_set_results;
@@collation_connection @@character_set_results
cp1251_general_ci cp1251
SELECT
CHARSET(ADDTIME(_latin1'10:01:01',_latin1'10:00:00')) AS addtime1,
CHARSET(ADDTIME('10:01:01','10:00:00')) AS addtime2,
CHARSET(DATE_ADD(_latin1'2001-01-01 10:01:01',interval 10 second)) AS date_add1,
CHARSET(DATE_ADD('2001-01-01 10:01:01',interval 10 second)) AS date_add2;
addtime1 addtime2 date_add1 date_add2
cp1251 cp1251 cp1251 cp1251
CREATE TABLE t1 AS
SELECT
ADDTIME(_latin1'10:01:01',_latin1'10:00:00') AS addtime1,
ADDTIME('10:01:01','10:00:00') AS addtime2,
DATE_ADD(_latin1'2001-01-01 10:01:01',interval 10 second) AS date_add1,
DATE_ADD('2001-01-01 10:01:01',interval 10 second) AS date_add2;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`addtime1` varchar(26) CHARACTER SET cp1251 DEFAULT NULL,
`addtime2` varchar(26) CHARACTER SET cp1251 DEFAULT NULL,
`date_add1` varchar(19) CHARACTER SET cp1251 DEFAULT NULL,
`date_add2` varchar(19) CHARACTER SET cp1251 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t1;
addtime1 addtime2 date_add1 date_add2
20:01:01 20:01:01 2001-01-01 10:01:11 2001-01-01 10:01:11
DROP TABLE t1;
#
# Bug#11926811 / Bug#60625 Illegal mix of collations
#
SELECT @@collation_connection;

View file

@ -3351,6 +3351,13 @@ DROP TABLE t1;
SELECT @@collation_connection, @@character_set_results;
@@collation_connection @@character_set_results
latin1_swedish_ci latin1
SELECT
CHARSET(DATE_SUB('2007-08-03', INTERVAL 1 MINUTE)) AS field_str1,
CHARSET(DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE)) AS field_str2,
CHARSET(DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY)) AS field_date,
CHARSET(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS field_datetime;
field_str1 field_str2 field_date field_datetime
latin1 latin1 binary binary
CREATE TABLE t1 AS
SELECT
DATE_SUB('2007-08-03', INTERVAL 1 MINUTE) AS field_str1,
@ -3372,8 +3379,8 @@ DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def field_str1 254 19 10 Y 128 0 63
def field1_str2 254 19 19 Y 128 0 63
def field_str1 254 19 10 Y 0 0 8
def field1_str2 254 19 19 Y 0 0 8
def field_date 10 10 10 Y 128 0 63
def field_datetime 12 19 19 Y 128 0 63
field_str1 field1_str2 field_date field_datetime
@ -3386,6 +3393,37 @@ HEX(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS fie
field_str1 field1_str2 field_date field_datetime
323030372D30382D30322032333A35393A3030 323030372D30382D30332031373A33323A3030 323030372D30382D3032 323030372D30382D30332031373A33323A3030
#
# MDEV-4841 Wrong character set of ADDTIME() and DATE_ADD()
#
SELECT @@collation_connection, @@character_set_results;
@@collation_connection @@character_set_results
latin1_swedish_ci latin1
SELECT
CHARSET(ADDTIME(_latin1'10:01:01',_latin1'10:00:00')) AS addtime1,
CHARSET(ADDTIME('10:01:01','10:00:00')) AS addtime2,
CHARSET(DATE_ADD(_latin1'2001-01-01 10:01:01',interval 10 second)) AS date_add1,
CHARSET(DATE_ADD('2001-01-01 10:01:01',interval 10 second)) AS date_add2;
addtime1 addtime2 date_add1 date_add2
latin1 latin1 latin1 latin1
CREATE TABLE t1 AS
SELECT
ADDTIME(_latin1'10:01:01',_latin1'10:00:00') AS addtime1,
ADDTIME('10:01:01','10:00:00') AS addtime2,
DATE_ADD(_latin1'2001-01-01 10:01:01',interval 10 second) AS date_add1,
DATE_ADD('2001-01-01 10:01:01',interval 10 second) AS date_add2;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`addtime1` varchar(26) DEFAULT NULL,
`addtime2` varchar(26) DEFAULT NULL,
`date_add1` varchar(19) DEFAULT NULL,
`date_add2` varchar(19) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t1;
addtime1 addtime2 date_add1 date_add2
20:01:01 20:01:01 2001-01-01 10:01:11 2001-01-01 10:01:11
DROP TABLE t1;
#
# Bug#11926811 / Bug#60625 Illegal mix of collations
#
SELECT @@collation_connection;

View file

@ -4167,6 +4167,13 @@ DROP TABLE t1;
SELECT @@collation_connection, @@character_set_results;
@@collation_connection @@character_set_results
ucs2_general_ci latin1
SELECT
CHARSET(DATE_SUB('2007-08-03', INTERVAL 1 MINUTE)) AS field_str1,
CHARSET(DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE)) AS field_str2,
CHARSET(DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY)) AS field_date,
CHARSET(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS field_datetime;
field_str1 field_str2 field_date field_datetime
ucs2 ucs2 binary binary
CREATE TABLE t1 AS
SELECT
DATE_SUB('2007-08-03', INTERVAL 1 MINUTE) AS field_str1,
@ -4176,8 +4183,8 @@ DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_da
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`field_str1` varchar(19) DEFAULT NULL,
`field1_str2` varchar(19) DEFAULT NULL,
`field_str1` varchar(19) CHARACTER SET ucs2 DEFAULT NULL,
`field1_str2` varchar(19) CHARACTER SET ucs2 DEFAULT NULL,
`field_date` date DEFAULT NULL,
`field_datetime` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
@ -4188,8 +4195,8 @@ DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def field_str1 254 19 10 Y 128 0 63
def field1_str2 254 19 19 Y 128 0 63
def field_str1 254 19 10 Y 0 0 8
def field1_str2 254 19 19 Y 0 0 8
def field_date 10 10 10 Y 128 0 63
def field_datetime 12 19 19 Y 128 0 63
field_str1 field1_str2 field_date field_datetime
@ -4200,7 +4207,38 @@ HEX(DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE)) AS field1_str2,
HEX(DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY)) AS field_date,
HEX(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS field_datetime;
field_str1 field1_str2 field_date field_datetime
323030372D30382D30322032333A35393A3030 323030372D30382D30332031373A33323A3030 323030372D30382D3032 323030372D30382D30332031373A33323A3030
0032003000300037002D00300038002D00300032002000320033003A00350039003A00300030 0032003000300037002D00300038002D00300033002000310037003A00330032003A00300030 323030372D30382D3032 323030372D30382D30332031373A33323A3030
#
# MDEV-4841 Wrong character set of ADDTIME() and DATE_ADD()
#
SELECT @@collation_connection, @@character_set_results;
@@collation_connection @@character_set_results
ucs2_general_ci latin1
SELECT
CHARSET(ADDTIME(_latin1'10:01:01',_latin1'10:00:00')) AS addtime1,
CHARSET(ADDTIME('10:01:01','10:00:00')) AS addtime2,
CHARSET(DATE_ADD(_latin1'2001-01-01 10:01:01',interval 10 second)) AS date_add1,
CHARSET(DATE_ADD('2001-01-01 10:01:01',interval 10 second)) AS date_add2;
addtime1 addtime2 date_add1 date_add2
ucs2 ucs2 ucs2 ucs2
CREATE TABLE t1 AS
SELECT
ADDTIME(_latin1'10:01:01',_latin1'10:00:00') AS addtime1,
ADDTIME('10:01:01','10:00:00') AS addtime2,
DATE_ADD(_latin1'2001-01-01 10:01:01',interval 10 second) AS date_add1,
DATE_ADD('2001-01-01 10:01:01',interval 10 second) AS date_add2;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`addtime1` varchar(26) CHARACTER SET ucs2 DEFAULT NULL,
`addtime2` varchar(26) CHARACTER SET ucs2 DEFAULT NULL,
`date_add1` varchar(19) CHARACTER SET ucs2 DEFAULT NULL,
`date_add2` varchar(19) CHARACTER SET ucs2 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t1;
addtime1 addtime2 date_add1 date_add2
20:01:01 20:01:01 2001-01-01 10:01:11 2001-01-01 10:01:11
DROP TABLE t1;
#
# Bug#11926811 / Bug#60625 Illegal mix of collations
#

View file

@ -4988,6 +4988,13 @@ DROP TABLE t1;
SELECT @@collation_connection, @@character_set_results;
@@collation_connection @@character_set_results
utf8_general_ci utf8
SELECT
CHARSET(DATE_SUB('2007-08-03', INTERVAL 1 MINUTE)) AS field_str1,
CHARSET(DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE)) AS field_str2,
CHARSET(DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY)) AS field_date,
CHARSET(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS field_datetime;
field_str1 field_str2 field_date field_datetime
utf8 utf8 binary binary
CREATE TABLE t1 AS
SELECT
DATE_SUB('2007-08-03', INTERVAL 1 MINUTE) AS field_str1,
@ -4997,8 +5004,8 @@ DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_da
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`field_str1` varchar(19) DEFAULT NULL,
`field1_str2` varchar(19) DEFAULT NULL,
`field_str1` varchar(19) CHARACTER SET utf8 DEFAULT NULL,
`field1_str2` varchar(19) CHARACTER SET utf8 DEFAULT NULL,
`field_date` date DEFAULT NULL,
`field_datetime` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
@ -5009,8 +5016,8 @@ DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def field_str1 254 19 10 Y 128 0 63
def field1_str2 254 19 19 Y 128 0 63
def field_str1 254 57 10 Y 0 0 33
def field1_str2 254 57 19 Y 0 0 33
def field_date 10 10 10 Y 128 0 63
def field_datetime 12 19 19 Y 128 0 63
field_str1 field1_str2 field_date field_datetime
@ -5023,6 +5030,37 @@ HEX(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS fie
field_str1 field1_str2 field_date field_datetime
323030372D30382D30322032333A35393A3030 323030372D30382D30332031373A33323A3030 323030372D30382D3032 323030372D30382D30332031373A33323A3030
#
# MDEV-4841 Wrong character set of ADDTIME() and DATE_ADD()
#
SELECT @@collation_connection, @@character_set_results;
@@collation_connection @@character_set_results
utf8_general_ci utf8
SELECT
CHARSET(ADDTIME(_latin1'10:01:01',_latin1'10:00:00')) AS addtime1,
CHARSET(ADDTIME('10:01:01','10:00:00')) AS addtime2,
CHARSET(DATE_ADD(_latin1'2001-01-01 10:01:01',interval 10 second)) AS date_add1,
CHARSET(DATE_ADD('2001-01-01 10:01:01',interval 10 second)) AS date_add2;
addtime1 addtime2 date_add1 date_add2
utf8 utf8 utf8 utf8
CREATE TABLE t1 AS
SELECT
ADDTIME(_latin1'10:01:01',_latin1'10:00:00') AS addtime1,
ADDTIME('10:01:01','10:00:00') AS addtime2,
DATE_ADD(_latin1'2001-01-01 10:01:01',interval 10 second) AS date_add1,
DATE_ADD('2001-01-01 10:01:01',interval 10 second) AS date_add2;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`addtime1` varchar(26) CHARACTER SET utf8 DEFAULT NULL,
`addtime2` varchar(26) CHARACTER SET utf8 DEFAULT NULL,
`date_add1` varchar(19) CHARACTER SET utf8 DEFAULT NULL,
`date_add2` varchar(19) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t1;
addtime1 addtime2 date_add1 date_add2
20:01:01 20:01:01 2001-01-01 10:01:11 2001-01-01 10:01:11
DROP TABLE t1;
#
# Bug#11926811 / Bug#60625 Illegal mix of collations
#
SELECT @@collation_connection;
@ -5869,5 +5907,31 @@ SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65537) AS data) AS sub;
len
131074
#
# MDEV-10717 Assertion `!null_value' failed in virtual bool Item::send(Protocol*, String*)
#
CREATE TABLE t1 (i INT, KEY(i));
INSERT INTO t1 VALUES (20081205),(20050327);
SELECT HEX(i), HEX(CHAR(i USING utf8)) FROM t1;
HEX(i) HEX(CHAR(i USING utf8))
131F197 0131
1326A35 01326A35
Warnings:
Warning 1300 Invalid utf8 character string: 'F197'
SET sql_mode='STRICT_ALL_TABLES';
SELECT HEX(i), HEX(CHAR(i USING utf8)) FROM t1;
HEX(i) HEX(CHAR(i USING utf8))
131F197 NULL
1326A35 01326A35
Warnings:
Warning 1300 Invalid utf8 character string: 'F197'
SELECT CHAR(i USING utf8) FROM t1;
CHAR(i USING utf8)
###
###
Warnings:
### 1300 Invalid utf8 character string: 'F197'
SET sql_mode=DEFAULT;
DROP TABLE t1;
#
# End of 5.5 tests
#

View file

@ -924,3 +924,68 @@ id select_type table type possible_keys key key_len ref rows Extra
3 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
DROP TABLES t1,t2;
#
# MDEV-10663: Use of Inline table columns in HAVING clause
# throws 1463 Error
#
set @save_sql_mode = @@sql_mode;
set sql_mode='ONLY_FULL_GROUP_BY,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
CREATE TABLE `example1463` (
`Customer` varchar(255) NOT NULL,
`DeliveryStatus` varchar(255) NOT NULL,
`OrderSize` int(11) NOT NULL
);
INSERT INTO example1463 VALUES ('Charlie', 'Success', 100);
INSERT INTO example1463 VALUES ('David', 'Success', 110);
INSERT INTO example1463 VALUES ('Charlie', 'Failed', 200);
INSERT INTO example1463 VALUES ('David', 'Success', 100);
INSERT INTO example1463 VALUES ('David', 'Unknown', 100);
INSERT INTO example1463 VALUES ('Edward', 'Success', 150);
INSERT INTO example1463 VALUES ('Edward', 'Pending', 150);
SELECT Customer, Success, SUM(OrderSize)
FROM (SELECT Customer,
CASE WHEN DeliveryStatus='Success' THEN 'Yes' ELSE 'No' END AS Success,
OrderSize
FROM example1463) as subQ
GROUP BY Success, Customer
WITH ROLLUP;
Customer Success SUM(OrderSize)
Charlie No 200
David No 100
Edward No 150
NULL No 450
Charlie Yes 100
David Yes 210
Edward Yes 150
NULL Yes 460
NULL NULL 910
SELECT Customer, Success, SUM(OrderSize)
FROM (SELECT Customer,
CASE WHEN DeliveryStatus='Success' THEN 'Yes' ELSE 'No' END AS Success,
OrderSize
FROM example1463) as subQ
GROUP BY Success, Customer;
Customer Success SUM(OrderSize)
Charlie No 200
David No 100
Edward No 150
Charlie Yes 100
David Yes 210
Edward Yes 150
SELECT Customer, Success, SUM(OrderSize)
FROM (SELECT Customer,
CASE WHEN DeliveryStatus='Success' THEN 'Yes' ELSE 'No' END AS Success,
OrderSize
FROM example1463) as subQ
GROUP BY Success, Customer
HAVING Success IS NOT NULL;
Customer Success SUM(OrderSize)
Charlie No 200
David No 100
Edward No 150
Charlie Yes 100
David Yes 210
Edward Yes 150
DROP TABLE example1463;
set sql_mode= @save_sql_mode;
# end of 5.5

View file

@ -2496,5 +2496,88 @@ DROP TABLE t1,t2;
#
# end of 5.3 tests
#
#
# Bug mdev-11161: The second execution of prepared statement
# does not use generated key for materialized
# derived table / view
# (actually this is a 5.3 bug.)
#
create table t1 (
mat_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
matintnum CHAR(6) NOT NULL,
test MEDIUMINT UNSIGNED NULL
);
create table t2 (
mat_id MEDIUMINT UNSIGNED NOT NULL,
pla_id MEDIUMINT UNSIGNED NOT NULL
);
insert into t1 values
(NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd', 4),
(NULL, 'e', 5), (NULL, 'f', 6), (NULL, 'g', 7), (NULL, 'h', 8),
(NULL, 'i', 9);
insert into t2 values
(1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104),
(3, 101), (3, 102), (3, 105);
explain
SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id
FROM t1 m2
INNER JOIN
(SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum
FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id
GROUP BY mp.pla_id) d
ON d.matintnum=m2.matintnum;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY m2 ALL NULL NULL NULL NULL 9
1 PRIMARY <derived2> ref key0 key0 7 test.m2.matintnum 2
2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
2 DERIVED m1 eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1
prepare stmt1 from
"SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id
FROM t1 m2
INNER JOIN
(SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum
FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id
GROUP BY mp.pla_id) d
ON d.matintnum=m2.matintnum";
flush status;
execute stmt1;
pla_id mat_id
102 1
101 1
100 1
104 2
103 2
105 3
show status like '%Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 21
Handler_read_last 0
Handler_read_next 6
Handler_read_prev 0
Handler_read_rnd 6
Handler_read_rnd_deleted 0
Handler_read_rnd_next 27
flush status;
execute stmt1;
pla_id mat_id
102 1
101 1
100 1
104 2
103 2
105 3
show status like '%Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 21
Handler_read_last 0
Handler_read_next 6
Handler_read_prev 0
Handler_read_rnd 6
Handler_read_rnd_deleted 0
Handler_read_rnd_next 27
deallocate prepare stmt1;
drop table t1,t2;
set optimizer_switch=@exit_optimizer_switch;
set join_cache_level=@exit_join_cache_level;

View file

@ -0,0 +1,12 @@
set @event_scheduler_save= @@global.event_scheduler;
set @slow_query_log_save= @@global.slow_query_log;
set global event_scheduler= on;
set global slow_query_log= on;
set global long_query_time=0.2;
create table t1 (i int);
insert into t1 values (0);
create event ev on schedule at CURRENT_TIMESTAMP + INTERVAL 1 second do update t1 set i=1+sleep(0.5);
drop table t1;
set global event_scheduler= @event_scheduler_save;
set global slow_query_log= @slow_query_log_save;
set global long_query_time= @@session.long_query_time;

View file

@ -0,0 +1,7 @@
set names utf8mb4;
create table t1 (a int, b text, fulltext (b)) charset=utf8mb4 collate=utf8mb4_unicode_ci;
insert t1 values (1000, 'C͓̙̯͔̩ͅͅi̩̘̜̲a̯̲̬̳̜̖̤o͕͓̜͓̺̖̗,̠̬͚ ̺T͇̲h͈̱e ̬̜D̖o̦̖͔̗͖̩̘c̣̼t̝͉̫̮̗o͉̫̭r̙͎̗.͓̪̥');
select a from t1 where match(b) against ('ciao' in boolean mode);
a
1000
drop table t1;

View file

@ -2620,3 +2620,9 @@ id date1 date2 DATE_ADD(a.date1,INTERVAL -10 DAY) TO_DAYS(a.date1)-10
17 NULL NULL NULL NULL
18 2010-10-13 2010-10-03 2010-10-03 734413
DROP TABLE t1;
#
# MDEV-10524 Assertion `arg1_int >= 0' failed in Item_func_additive_op::result_precision()
#
SELECT 1 MOD ADDTIME( '13:58:57', '00:00:01' ) + 2;
1 MOD ADDTIME( '13:58:57', '00:00:01' ) + 2
3

View file

@ -2517,3 +2517,17 @@ MAX(i) c
0 bar
7 foo
drop table t1,t2;
#
# ONLY_FULL_GROUP_BY references
#
set @save_sql_mode = @@sql_mode;
set sql_mode='ONLY_FULL_GROUP_BY';
create table t1 (a int, b int);
select a+b as x from t1 group by x having x > 1;
x
select a as x from t1 group by x having x > 1;
x
select a from t1 group by a having a > 1;
a
drop table t1;
set sql_mode= @save_sql_mode;

View file

@ -793,3 +793,32 @@ a b c
9 d d
DROP TABLE t1;
set optimizer_switch= @optimizer_switch_save;
#
# MDEV-10927: Crash When Using sort_union Optimization
#
set @tmp_optimizer_switch=@@optimizer_switch;
SET optimizer_switch='index_merge_sort_intersection=on';
SET SESSION sort_buffer_size = 1024;
create table t1 (
pk int(11) NOT NULL AUTO_INCREMENT,
col1 int(11) NOT NULL,
col2 int(11) NOT NULL,
col3 int(11) NOT NULL,
key2 int(11) NOT NULL,
col4 int(11) NOT NULL,
key1 int(11) NOT NULL,
PRIMARY KEY (pk),
KEY key1 (key1),
KEY key2 (key2)
) ENGINE=InnoDB AUTO_INCREMENT=12860259 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
create table t2(a int);
insert into t2 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t3(a int);
insert into t3 select A.a + B.a* 10 + C.a * 100 + D.a*1000 from t2 A, t2 B, t2 C, t2 D;
insert into t1 (key1, key2, col1,col2,col3,col4)
select a,a, a,a,a,a from t3;
SELECT sum(col1) FROM t1 FORCE INDEX (key1,key2) WHERE (key1 between 10 and 8191+10) or (key2= 5);
sum(col1)
33632261
drop table t1,t2,t3;
set optimizer_switch=@tmp_optimizer_switch;

View file

@ -986,19 +986,19 @@ show grants;
Grants for user3@localhost
GRANT USAGE ON *.* TO 'user3'@'localhost'
GRANT SELECT ON `mysqltest`.* TO 'user3'@'localhost'
select * from information_schema.column_privileges where grantee like '%user%'
select * from information_schema.column_privileges where grantee like '\'user%'
order by grantee;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
'user1'@'localhost' def mysqltest t1 f1 SELECT NO
select * from information_schema.table_privileges where grantee like '%user%'
select * from information_schema.table_privileges where grantee like '\'user%'
order by grantee;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
'user2'@'localhost' def mysqltest t2 SELECT NO
select * from information_schema.schema_privileges where grantee like '%user%'
select * from information_schema.schema_privileges where grantee like '\'user%'
order by grantee;
GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE
'user3'@'localhost' def mysqltest SELECT NO
select * from information_schema.user_privileges where grantee like '%user%'
select * from information_schema.user_privileges where grantee like '\'user%'
order by grantee;
GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE
'user1'@'localhost' def USAGE NO

View file

@ -151,3 +151,11 @@ select create_options from information_schema.tables where table_schema="test";
create_options
partitioned
drop table t1;
#
# MDEV-11353 - Identical logical conditions
#
CREATE TABLE t1(a INT) CHECKSUM=1 SELECT 1;
SELECT CHECKSUM FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
CHECKSUM
3036305396
DROP TABLE t1;

View file

@ -507,7 +507,7 @@ DROP TABLE t1;
# Bug#11765139 58069: LOAD DATA INFILE: VALGRIND REPORTS INVALID MEMORY READS AND WRITES WITH U
#
CREATE TABLE t1(f1 INT);
SELECT 0xE1C330 INTO OUTFILE 't1.dat';
SELECT 0xE1BB30 INTO OUTFILE 't1.dat';
LOAD DATA INFILE 't1.dat' IGNORE INTO TABLE t1 CHARACTER SET utf8;
DROP TABLE t1;
#
@ -532,27 +532,3 @@ FIELDS TERMINATED BY 't' LINES TERMINATED BY '';
Got one of the listed errors
SET @@sql_mode= @old_mode;
DROP TABLE t1;
#
# Bug#23080148 - Backport of Bug#20683959.
# Bug#20683959 LOAD DATA INFILE IGNORES A SPECIFIC ROW SILENTLY
# UNDER DB CHARSET IS UTF8.
#
CREATE DATABASE d1 CHARSET latin1;
USE d1;
CREATE TABLE t1 (val TEXT);
LOAD DATA INFILE '../../std_data/bug20683959loaddata.txt' INTO TABLE t1;
SELECT COUNT(*) FROM t1;
COUNT(*)
1
SELECT HEX(val) FROM t1;
HEX(val)
C38322525420406E696F757A656368756E3A20E98198E2889AF58081AEE7B99DE4B88AE383A3E7B99DE69690F58087B3E7B9A7EFBDA8E7B99DEFBDB3E7B99DE78999E880B3E7B8BAEFBDAAE7B9A7E89699E296A1E7B8BAE4BBA3EFBD8CE7B8BAEFBDA9E7B8B2E2889AE38184E7B99DEFBDB3E7B99DE4B88AE383A3E7B99DE69690F58087B3E7B9A7EFBDA8E7B99DEFBDB3E7B99DE5B3A8EFBD84E8ABA0EFBDA8E89C89F580948EE599AAE7B8BAEFBDAAE7B8BAE9A198EFBDA9EFBDB1E7B9A7E581B5E289A0E7B8BAEFBDBEE7B9A7E9A194EFBDA9E882B4EFBDA5EFBDB5E980A7F5808B96E28693E99EABE38287E58F99E7B8BAE58AB1E28691E7B8BAF5808B9AE7828AE98095EFBDB1E7B8BAEFBDAFE7B8B2E288ABE6A89FE89EB3E6BA98F58081ADE88EA0EFBDBAE98095E6BA98F58081AEE89D93EFBDBAE8AD9BEFBDACE980A7F5808B96E28693E7B8BAF580918EE288AAE7B8BAE4B88AEFBC9EE7B8BAE4B99DE28691E7B8BAF5808B96EFBCA0E88DB3E6A68AEFBDB9EFBDB3E981B2E5B3A8E296A1E7B8BAE7A4BCE7828AE88DB3E6A68AEFBDB0EFBDBDE7B8BAA0E7B8BAE88B93EFBDBEE5B899EFBC9E
CREATE DATABASE d2 CHARSET utf8;
USE d2;
CREATE TABLE t1 (val TEXT);
LOAD DATA INFILE '../../std_data/bug20683959loaddata.txt' INTO TABLE t1;
ERROR HY000: Invalid utf8 character string: 'Ã"RT @niouzechun: \9058\221A'
DROP TABLE d1.t1, d2.t1;
DROP DATABASE d1;
DROP DATABASE d2;

View file

@ -663,3 +663,12 @@ select 1<<!0, 1 << !0;
select 0<!0, 0 < ! 0;
0<!0 0 < ! 0
1 1
#
# MDEV-11171 Assertion `m_cpp_buf <= ptr && ptr <= m_cpp_buf + m_buf_length' failed in Lex_input_stream::body_utf8_append(const char*, const char*)
#
CREATE TABLE t1 (id INT);
CREATE TRIGGER tr AFTER DELETE ON t1 FOR EACH ROW SET @a = 1\;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '\' at line 1
PREPARE stmt FROM 'CREATE TRIGGER tr AFTER DELETE ON t1 FOR EACH ROW SET @a = 1\\';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '\' at line 1
DROP TABLE t1;

View file

@ -8016,4 +8016,43 @@ Warnings:
Error 1329 No data - zero rows fetched, selected, or processed
DROP PROCEDURE p1;
DROP TABLE t1;
#
# MDEV-10713: signal 11 error on multi-table update - crash in
# handler::increment_statistics or in make_select or assertion
# failure pfs_thread == ((PFS_thread*) pthread_getspecific((THR_PFS)))
#
CREATE TABLE `t1` (
`CLOSE_YN` varchar(10) COLLATE utf8_bin DEFAULT NULL
) DEFAULT CHARSET=utf8 COLLATE=utf8_bin ;
CREATE TABLE `t2` (
`ap_close_to` varchar(8) COLLATE utf8_bin DEFAULT NULL
) DEFAULT CHARSET=utf8 COLLATE=utf8_bin ;
insert t1 values (1);
CREATE FUNCTION `f1`(`P_DC_CD` VARBINARY(50), `P_SYS_DATE` DATETIME) RETURNS datetime
DETERMINISTIC
SQL SECURITY INVOKER
BEGIN
DECLARE V_SYS_DATE DATETIME;
SELECT now() AS LOC_DATE INTO V_SYS_DATE ;
RETURN v_sys_date ;
END $$
update t1 S
JOIN
(
SELECT CASE
WHEN DATE_FORMAT( f1('F01', NOW()) , '%Y%m%d') <= CLOSE_YMD
THEN '99991231'
ELSE '' END ACCOUNT_APPLY_YYYYMMDD
FROM (
select case
when 'AP'='AP'
then ap_close_to
end AS CLOSE_YMD
from t2
) A
) X
SET S.CLOSE_YN = ''
where 1=1;
drop function if exists f1;
drop table t1,t2;
# End of 5.5 test

View file

@ -7094,3 +7094,25 @@ a
0
DROP TABLE t1;
SET SESSION big_tables=0;
#
# MDEV-10776: Server crash on query
#
create table t1 (field1 int);
insert into t1 values (1);
select round((select 1 from t1 limit 1))
from t1
group by round((select 1 from t1 limit 1));
round((select 1 from t1 limit 1))
1
drop table t1;
#
# MDEV-10386 Assertion `fixed == 1' failed in virtual String* Item_func_conv_charset::val_str(String*)
#
CREATE TABLE t1 (f1 CHAR(3) CHARACTER SET utf8 NULL, f2 CHAR(3) CHARACTER SET latin1 NULL);
INSERT INTO t1 VALUES ('foo','bar');
SELECT * FROM t1 WHERE f2 >= SOME ( SELECT f1 FROM t1 );
f1 f2
SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
f1 f2
foo bar
DROP TABLE t1;

View file

@ -348,4 +348,49 @@ where t1.a = t2.a and ( t1.a = ( select min(a) from t1 ) or 0 );
a a a
FRA FRA FRA
drop table t1,t2,t3;
#
# MDEV-10148: Database crashes in the query to the View
#
CREATE TABLE t1 (
key_code INT(11) NOT NULL,
value_string VARCHAR(50) NULL DEFAULT NULL,
PRIMARY KEY (key_code)
) COLLATE='utf8_general_ci' ENGINE=InnoDB ;
CREATE TABLE t2 (
key_code INT(11) NOT NULL,
target_date DATE NULL DEFAULT NULL,
PRIMARY KEY (key_code)
) COLLATE='utf8_general_ci' ENGINE=InnoDB ;
CREATE TABLE t3 (
now_date DATE NOT NULL,
PRIMARY KEY (now_date)
) COLLATE='utf8_general_ci' ENGINE=InnoDB ;
CREATE VIEW v1
AS
SELECT
B.key_code,
B.target_date
FROM
t2 B INNER JOIN t3 C ON
B.target_date = C.now_date
;
SET @s = 'SELECT A.* FROM t1 A WHERE A.key_code IN (SELECT key_code FROM v1)';
PREPARE stmt FROM @s;
EXECUTE stmt;
key_code value_string
EXECUTE stmt;
key_code value_string
DEALLOCATE PREPARE stmt;
DROP VIEW v1;
DROP TABLE t1,t2,t3;
set optimizer_switch=@subselect2_test_tmp;
create table t1 (a int);
create table t2 (a int);
create table t3(a int);
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
insert into t2 select a from t1;
insert into t3 select a from t1;
select null in (select a from t1 where a < out3.a union select a from t2 where
(select a from t3) +1 < out3.a+1) from t3 out3;
ERROR 21000: Subquery returns more than 1 row
drop table t1, t2, t3;

View file

@ -2410,5 +2410,44 @@ SELECT x FROM t1 WHERE id > (SELECT MAX(id) - 1000 FROM t1) ORDER BY x LIMIT 1;
x
0
drop table t1;
#
# MDEV-7691: Assertion `outer_context || !*from_field || *from_field == not_found_field' ...
#
set optimizer_switch=default;
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (4),(6);
CREATE TABLE t2 (b INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1),(8);
PREPARE stmt FROM "
SELECT * FROM t2
HAVING 0 IN (
SELECT a FROM t1
WHERE a IN (
SELECT a FROM t1
WHERE b = a
)
)
";
EXECUTE stmt;
b
EXECUTE stmt;
b
# Alternative test case, without HAVING
CREATE TABLE t3 (i INT) ENGINE=MyISAM;
INSERT INTO t3 VALUES (4),(6);
PREPARE stmt FROM "
SELECT * FROM t3 AS t10
WHERE EXISTS (
SELECT * FROM t3 AS t20 WHERE t10.i IN (
SELECT i FROM t3
)
)";
EXECUTE stmt;
i
6
EXECUTE stmt;
i
6
drop table t1, t2, t3;
SET optimizer_switch= @@global.optimizer_switch;
set @@tmp_table_size= @@global.tmp_table_size;

View file

@ -7091,6 +7091,28 @@ a
0
DROP TABLE t1;
SET SESSION big_tables=0;
#
# MDEV-10776: Server crash on query
#
create table t1 (field1 int);
insert into t1 values (1);
select round((select 1 from t1 limit 1))
from t1
group by round((select 1 from t1 limit 1));
round((select 1 from t1 limit 1))
1
drop table t1;
#
# MDEV-10386 Assertion `fixed == 1' failed in virtual String* Item_func_conv_charset::val_str(String*)
#
CREATE TABLE t1 (f1 CHAR(3) CHARACTER SET utf8 NULL, f2 CHAR(3) CHARACTER SET latin1 NULL);
INSERT INTO t1 VALUES ('foo','bar');
SELECT * FROM t1 WHERE f2 >= SOME ( SELECT f1 FROM t1 );
f1 f2
SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
f1 f2
foo bar
DROP TABLE t1;
set optimizer_switch=default;
select @@optimizer_switch like '%materialization=on%';
@@optimizer_switch like '%materialization=on%'

View file

@ -7089,4 +7089,26 @@ a
0
DROP TABLE t1;
SET SESSION big_tables=0;
#
# MDEV-10776: Server crash on query
#
create table t1 (field1 int);
insert into t1 values (1);
select round((select 1 from t1 limit 1))
from t1
group by round((select 1 from t1 limit 1));
round((select 1 from t1 limit 1))
1
drop table t1;
#
# MDEV-10386 Assertion `fixed == 1' failed in virtual String* Item_func_conv_charset::val_str(String*)
#
CREATE TABLE t1 (f1 CHAR(3) CHARACTER SET utf8 NULL, f2 CHAR(3) CHARACTER SET latin1 NULL);
INSERT INTO t1 VALUES ('foo','bar');
SELECT * FROM t1 WHERE f2 >= SOME ( SELECT f1 FROM t1 );
f1 f2
SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
f1 f2
foo bar
DROP TABLE t1;
set @optimizer_switch_for_subselect_test=null;

View file

@ -7100,6 +7100,28 @@ a
0
DROP TABLE t1;
SET SESSION big_tables=0;
#
# MDEV-10776: Server crash on query
#
create table t1 (field1 int);
insert into t1 values (1);
select round((select 1 from t1 limit 1))
from t1
group by round((select 1 from t1 limit 1));
round((select 1 from t1 limit 1))
1
drop table t1;
#
# MDEV-10386 Assertion `fixed == 1' failed in virtual String* Item_func_conv_charset::val_str(String*)
#
CREATE TABLE t1 (f1 CHAR(3) CHARACTER SET utf8 NULL, f2 CHAR(3) CHARACTER SET latin1 NULL);
INSERT INTO t1 VALUES ('foo','bar');
SELECT * FROM t1 WHERE f2 >= SOME ( SELECT f1 FROM t1 );
f1 f2
SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
f1 f2
foo bar
DROP TABLE t1;
set optimizer_switch=default;
select @@optimizer_switch like '%subquery_cache=on%';
@@optimizer_switch like '%subquery_cache=on%'

View file

@ -7089,5 +7089,27 @@ a
0
DROP TABLE t1;
SET SESSION big_tables=0;
#
# MDEV-10776: Server crash on query
#
create table t1 (field1 int);
insert into t1 values (1);
select round((select 1 from t1 limit 1))
from t1
group by round((select 1 from t1 limit 1));
round((select 1 from t1 limit 1))
1
drop table t1;
#
# MDEV-10386 Assertion `fixed == 1' failed in virtual String* Item_func_conv_charset::val_str(String*)
#
CREATE TABLE t1 (f1 CHAR(3) CHARACTER SET utf8 NULL, f2 CHAR(3) CHARACTER SET latin1 NULL);
INSERT INTO t1 VALUES ('foo','bar');
SELECT * FROM t1 WHERE f2 >= SOME ( SELECT f1 FROM t1 );
f1 f2
SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
f1 f2
foo bar
DROP TABLE t1;
set @optimizer_switch_for_subselect_test=null;
set @join_cache_level_for_subselect_test=NULL;

View file

@ -221,7 +221,6 @@ drop table t1;
create table t1 (a decimal(10,2) unsigned);
insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
Warnings:
Warning 1264 Out of range value for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 6
insert into t1 values ("-.1"),("+.1"),(".1");
Warnings:
@ -280,7 +279,6 @@ drop table t1;
create table t1 (a decimal(10,2) zerofill);
insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
Warnings:
Warning 1264 Out of range value for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 6
insert into t1 values ("-.1"),("+.1"),(".1");
Warnings:
@ -1012,6 +1010,9 @@ SELECT COLUMN_NAME, DATA_TYPE, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE
COLUMN_NAME DATA_TYPE COLUMN_TYPE
a decimal decimal(10,2)/*old*/
DROP TABLE t1dec102;
select cast('-0.0' as decimal(5,1)) < 0;
cast('-0.0' as decimal(5,1)) < 0
0
#
# End of 5.5 tests
#

View file

@ -362,7 +362,7 @@ a
2
select found_rows();
found_rows()
6
5
SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION SELECT * FROM t2 LIMIT 100;
a
1
@ -1169,12 +1169,9 @@ a b
select * from ((select * from t1 limit 1) union (select * from t1 limit 1)) a;
a b
1 a
2 b
select * from ((select * from t1 limit 1) union (select * from t1 limit 1) union (select * from t1 limit 1)) a;
a b
1 a
2 b
3 c
select * from ((((select * from t1))) union (select * from t1) union (select * from t1)) a;
a b
1 a
@ -1553,7 +1550,6 @@ NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL Using filesort
Warnings:
Note 1003 select NULL AS `a` from `test`.`t1` union select NULL AS `a` from `test`.`t1` order by `a`
DROP TABLE t1;
End of 5.0 tests
#
# Bug#32858: Error: "Incorrect usage of UNION and INTO" does not take
# subselects into account
@ -1659,6 +1655,14 @@ a
4
5
6
(select a from t1 where false) UNION (select a from t1) limit 8;
a
10
2
3
4
5
6
7
8
drop table t1;
@ -1955,3 +1959,22 @@ cccc
bbbb
dddd
drop table t1;
#
# MDEV-10172: UNION query returns incorrect rows outside
# conditional evaluation
#
create table t1 (d datetime not null primary key);
insert into t1(d) values ('2016-06-01'),('2016-06-02'),('2016-06-03'),('2016-06-04');
select * from
(
select * from t1 where d between '2016-06-02' and '2016-06-05'
union
(select * from t1 where d < '2016-06-05' order by d desc limit 1)
) onlyJun2toJun4
order by d;
d
2016-06-02 00:00:00
2016-06-03 00:00:00
2016-06-04 00:00:00
drop table t1;
End of 5.0 tests

View file

@ -1 +0,0 @@
Ã"RT @niouzechun: 遘√<E98198><E2889A><EFBFBD><EFBFBD>繝上ャ繝斐<E7B99D><E69690><EFBFBD><EFBFBD>繧ィ繝ウ繝牙耳縺ェ繧薙□縺代縺ゥ縲√い繝ウ繝上ャ繝斐<E7B99D><E69690><EFBFBD><EFBFBD>繧ィ繝ウ繝峨諠ィ蜉<EFBDA8><E89C89><EFBFBD><EFBFBD>噪縺ェ縺願ゥア繧偵≠縺セ繧顔ゥ肴・オ逧<EFBDB5><E980A7><EFBFBD><EFBFBD>↓鞫ょ叙縺励↑縺<E28691><E7B8BA><EFBFBD><EFBFBD>炊逕ア縺ッ縲∫樟螳溘<E89EB3><E6BA98><EFBFBD><EFBFBD>莠コ逕溘<E98095><E6BA98><EFBFBD><EFBFBD>蝓コ譛ャ逧<EFBDAC><E980A7><EFBFBD><EFBFBD>↓縺<E28693><E7B8BA><EFBFBD><EFBFBD>縺上縺九↑縺<E28691><E7B8BA><EFBFBD><EFBFBD>荳榊ケウ遲峨□縺礼炊荳榊ース縺<EFBDBD>縺苓セ帙

View file

@ -1,9 +1,9 @@
call mtr.add_suppression('Attempting backtrace');
call mtr.add_suppression('MSYQL_BIN_LOG::purge_logs failed to process registered files that would be purged.');
call mtr.add_suppression('MSYQL_BIN_LOG::open failed to sync the index file');
call mtr.add_suppression('MYSQL_BIN_LOG::purge_logs failed to process registered files that would be purged.');
call mtr.add_suppression('MYSQL_BIN_LOG::open failed to sync the index file');
call mtr.add_suppression('Turning logging off for the whole duration of the MySQL server process.');
call mtr.add_suppression('Could not open .*');
call mtr.add_suppression('MSYQL_BIN_LOG::purge_logs failed to clean registers before purging logs.');
call mtr.add_suppression('MYSQL_BIN_LOG::purge_logs failed to clean registers before purging logs.');
flush tables;
RESET MASTER;
flush logs;

View file

@ -9,11 +9,11 @@ source include/have_debug.inc;
# Avoid CrashReporter popup on Mac
--source include/not_crashrep.inc
call mtr.add_suppression('Attempting backtrace');
call mtr.add_suppression('MSYQL_BIN_LOG::purge_logs failed to process registered files that would be purged.');
call mtr.add_suppression('MSYQL_BIN_LOG::open failed to sync the index file');
call mtr.add_suppression('MYSQL_BIN_LOG::purge_logs failed to process registered files that would be purged.');
call mtr.add_suppression('MYSQL_BIN_LOG::open failed to sync the index file');
call mtr.add_suppression('Turning logging off for the whole duration of the MySQL server process.');
call mtr.add_suppression('Could not open .*');
call mtr.add_suppression('MSYQL_BIN_LOG::purge_logs failed to clean registers before purging logs.');
call mtr.add_suppression('MYSQL_BIN_LOG::purge_logs failed to clean registers before purging logs.');
flush tables;
let $old=`select @@debug`;

View file

@ -48,7 +48,6 @@ Warning 1264 Out of range value for column 'c2' at row 1
Note 1265 Data truncated for column 'c3' at row 1
insert into t2 values ("0.0","0.0","0.0",7),("-0.0","-0.0","-0.0",8),("+0.0","+0.0","+0.0",9),("01.0","01.0","01.0",10),("+01.0","+01.0","+01.0",11),("-01.0","-01.0","-01.0",12);
Warnings:
Warning 1264 Out of range value for column 'c2' at row 2
Warning 1264 Out of range value for column 'c2' at row 6
insert into t2 values ("-.1","-.1","-.1",13),("+.1","+.1","+.1",14),(".1",".1",".1",15);
Warnings:

View file

@ -169,7 +169,7 @@ count(*)
SET SQL_LOG_BIN=1;
SET GLOBAL debug_dbug="-d,error_unique_log_filename";
###################### TEST #10
call mtr.add_suppression("MSYQL_BIN_LOG::open failed to sync the index file.");
call mtr.add_suppression("MYSQL_BIN_LOG::open failed to sync the index file.");
call mtr.add_suppression("Could not open .*");
RESET MASTER;
SHOW WARNINGS;
@ -226,7 +226,7 @@ include/rpl_reset.inc
call mtr.add_suppression("Slave I/O: Relay log write failure: could not queue event from master.*");
call mtr.add_suppression("Error writing file .*");
call mtr.add_suppression("Could not open .*");
call mtr.add_suppression("MSYQL_BIN_LOG::open failed to sync the index file.");
call mtr.add_suppression("MYSQL_BIN_LOG::open failed to sync the index file.");
call mtr.add_suppression("Can't generate a unique log-filename .*");
###################### TEST #13
SET @old_debug=@@global.debug;

View file

@ -1,14 +1,21 @@
include/master-slave.inc
[connection master]
---Setup Section --
set timestamp=1000000000;
DROP TABLE IF EXISTS t1,t2,t3;
CREATE TABLE t1(word VARCHAR(20));
CREATE TABLE t2(id INT AUTO_INCREMENT NOT NULL PRIMARY KEY);
CREATE TABLE t3(c1 INT NOT NULL PRIMARY KEY, c2 LONGBLOB, c3 TIMESTAMP, c4 TEXT, c5 FLOAT);
---Test1 check table load --
INSERT INTO t1 VALUES ("abirvalg");
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1;
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1;
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1;
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1;
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1;
set @d1 = 'dd1';
set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
---Test 1 check table load --
SELECT COUNT(*) from t1;
COUNT(*)
351
@ -71,9 +78,7 @@ c1 c3 c4 c5
5 2006-02-22 00:00:00 Tested in Texas 11
insert into t1 values ("Alas");
flush logs;
--- Test 1 Dump binlog to file --
--- Test 1 delete tables, clean master and slave --
DROP TABLE t1;
DROP TABLE t2;
@ -84,9 +89,7 @@ reset master;
reset slave;
start slave;
include/wait_for_slave_to_start.inc
--- Test 1 Load from Dump binlog file --
--- Test 1 Check Load Results --
SELECT COUNT(*) from t1;
COUNT(*)
@ -148,7 +151,6 @@ c1 c3 c4 c5
3 2006-02-22 00:00:00 Tested in Texas 6.6
4 2006-02-22 00:00:00 Tested in Texas 8.8
5 2006-02-22 00:00:00 Tested in Texas 11
--- Test 2 position test --
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
@ -172,7 +174,6 @@ DELIMITER ;
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
--- Test 3 First Remote test --
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
@ -189,9 +190,6 @@ SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
DROP TABLE IF EXISTS `t1`,`t2`,`t3` /* generated by server */
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
CREATE TABLE t1(word VARCHAR(20))
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
@ -205,7 +203,6 @@ DELIMITER ;
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
--- Test 4 Second Remote test --
DROP TABLE t1;
DROP TABLE t2;
@ -276,7 +273,6 @@ c1 c3 c4 c5
3 2006-02-22 00:00:00 Tested in Texas 6.6
4 2006-02-22 00:00:00 Tested in Texas 8.8
5 2006-02-22 00:00:00 Tested in Texas 11
--- Test 5 LOAD DATA --
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
@ -287,7 +283,6 @@ DELIMITER ;
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
--- Test 6 reading stdin --
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
@ -304,9 +299,6 @@ SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
DROP TABLE IF EXISTS `t1`,`t2`,`t3` /* generated by server */
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
CREATE TABLE t1(word VARCHAR(20))
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
@ -320,7 +312,6 @@ DELIMITER ;
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
--- Test 7 reading stdin w/position --
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
@ -344,7 +335,6 @@ DELIMITER ;
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
--- Test 8 switch internal charset --
stop slave;
include/wait_for_slave_to_stop.inc
@ -380,14 +370,13 @@ HEX(f)
select HEX(f) from t5;
HEX(f)
835C
--- Test cleanup --
DROP TABLE IF EXISTS t1;
DROP TABLE t1, t2, t3, t04, t05, t4, t5;
CREATE TABLE t1 (a INT NOT NULL KEY, b INT);
INSERT INTO t1 VALUES(1,1);
SELECT * FROM t1;
a b
1 1
FLUSH LOGS;
DROP TABLE IF EXISTS t1, t2, t3, t04, t05, t4, t5;
DROP TABLE t1;
include/rpl_end.inc

View file

@ -256,7 +256,7 @@ SET GLOBAL debug_dbug="-d,error_unique_log_filename";
### while registering the index file and the binary log
### file or failure to write the rotate event.
call mtr.add_suppression("MSYQL_BIN_LOG::open failed to sync the index file.");
call mtr.add_suppression("MYSQL_BIN_LOG::open failed to sync the index file.");
call mtr.add_suppression("Could not open .*");
RESET MASTER;
@ -362,7 +362,7 @@ RESET MASTER;
call mtr.add_suppression("Slave I/O: Relay log write failure: could not queue event from master.*");
call mtr.add_suppression("Error writing file .*");
call mtr.add_suppression("Could not open .*");
call mtr.add_suppression("MSYQL_BIN_LOG::open failed to sync the index file.");
call mtr.add_suppression("MYSQL_BIN_LOG::open failed to sync the index file.");
call mtr.add_suppression("Can't generate a unique log-filename .*");
-- echo ###################### TEST #13

View file

@ -4,43 +4,27 @@
# Purpose: To test changes to mysqlbinlog for row based bin logs #
# We are using .opt file since we need small binlog size #
##################################################################
# Include Section
# Make sure that we have row based bin log
-- source include/have_binlog_format_row.inc
# Embedded server doesn't support binlogging
-- source include/not_embedded.inc
# This test requires the cp932 charset compiled in
-- source include/have_cp932.inc
# Slow test, don't run during staging part
-- source include/not_staging.inc
-- source include/master-slave.inc
# Setup Section
--echo ---Setup Section --
# we need this for getting fixed timestamps inside of this test
--disable_query_log
select "---Setup Section --" as "";
--enable_query_log
set timestamp=1000000000;
--disable_warnings
DROP TABLE IF EXISTS t1,t2,t3;
--enable_warnings
connection master;
CREATE TABLE t1(word VARCHAR(20));
CREATE TABLE t2(id INT AUTO_INCREMENT NOT NULL PRIMARY KEY);
--let $position= query_get_value(SHOW MASTER STATUS, Position, 1)
--let position= query_get_value(SHOW MASTER STATUS, Position, 1)
CREATE TABLE t3(c1 INT NOT NULL PRIMARY KEY, c2 LONGBLOB, c3 TIMESTAMP, c4 TEXT, c5 FLOAT);
--let $stop_position=query_get_value(SHOW MASTER STATUS, Position, 1)
--let $stop_position1=`select $stop_position - 1`
--let $binlog_start_pos=query_get_value(SHOW BINLOG EVENTS LIMIT 1, End_log_pos, 1)
--let stop_position=query_get_value(SHOW MASTER STATUS, Position, 1)
--let stop_position1=`select $stop_position - 1`
--let binlog_start_pos=query_get_value(SHOW BINLOG EVENTS LIMIT 1, End_log_pos, 1)
# Test Section
# Lets start by putting some data into the tables.
--disable_query_log
INSERT INTO t1 VALUES ("abirvalg");
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1;
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1;
@ -54,7 +38,8 @@ set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
let $count=500;
--disable_query_log
let count=500;
while ($count)
{
INSERT INTO t2 VALUES (NULL);
@ -63,10 +48,7 @@ while ($count)
}
--enable_query_log
--disable_query_log
select "---Test1 check table load --" as "";
--enable_query_log
--echo ---Test 1 check table load --
# Lets Check the tables on the Master
SELECT COUNT(*) from t1;
@ -95,34 +77,26 @@ insert into t1 values ("Alas");
flush logs;
# delimiters are for easier debugging in future
--disable_query_log
select "--- Test 1 Dump binlog to file --" as "";
--enable_query_log
--echo --- Test 1 Dump binlog to file --
#
# Prepare local temporary file to recreate what we have currently.
let $MYSQLD_DATADIR= `select @@datadir;`;
let MYSQLD_DATADIR= `select @@datadir;`;
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/master.sql
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000002 >> $MYSQLTEST_VARDIR/tmp/master.sql
# Now that we have our file, lets get rid of the current database.
# Cleanup the master and the slave and try to recreate.
--disable_query_log
select "--- Test 1 delete tables, clean master and slave --" as "";
--enable_query_log
--echo --- Test 1 delete tables, clean master and slave --
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
sync_slave_with_master;
#we expect STOP SLAVE to produce a warning as the slave is stopped
#(the server was started with skip-slave-start)
--disable_warnings
stop slave;
--source include/wait_for_slave_to_stop.inc
--enable_warnings
connection master;
reset master;
connection slave;
@ -132,15 +106,11 @@ start slave;
connection master;
# We should be clean at this point, now we will run in the file from above.
--disable_query_log
select "--- Test 1 Load from Dump binlog file --" as "";
--enable_query_log
--echo --- Test 1 Load from Dump binlog file --
--exec $MYSQL -e "source $MYSQLTEST_VARDIR/tmp/master.sql"
--disable_query_log
select "--- Test 1 Check Load Results --" as "";
--enable_query_log
--echo --- Test 1 Check Load Results --
# Lets Check the tables on the Master
SELECT COUNT(*) from t1;
@ -168,28 +138,20 @@ remove_file $MYSQLTEST_VARDIR/tmp/master.sql;
# this test for start-position option
# By setting this position to 416, we should only get the create of t3
--disable_query_log
select "--- Test 2 position test --" as "";
--enable_query_log
let $MYSQLD_DATADIR= `select @@datadir;`;
--echo --- Test 2 position test --
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --start-position=$position --stop-position=$stop_position $MYSQLD_DATADIR/master-bin.000001
# These are tests for remote binlog.
# They should return the same as previous test.
--disable_query_log
select "--- Test 3 First Remote test --" as "";
--enable_query_log
--echo --- Test 3 First Remote test --
# This is broken now
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --stop-position=$stop_position --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
--disable_query_log
select "--- Test 4 Second Remote test --" as "";
--enable_query_log
--echo --- Test 4 Second Remote test --
--exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 > $MYSQLTEST_VARDIR/tmp/remote.sql
--exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 >> $MYSQLTEST_VARDIR/tmp/remote.sql
# Now that we have our file, lets get rid of the current database.
@ -201,13 +163,8 @@ DROP TABLE t3;
sync_slave_with_master;
#we expect STOP SLAVE to produce a warning as the slave is stopped
#(the server was started with skip-slave-start)
--disable_warnings
stop slave;
--source include/wait_for_slave_to_stop.inc
--enable_warnings
connection master;
reset master;
connection slave;
@ -251,40 +208,26 @@ connection master;
# transactions. /Matz
# LOAD DATA
--disable_query_log
select "--- Test 5 LOAD DATA --" as "";
--enable_query_log
--echo --- Test 5 LOAD DATA --
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --stop-position=$binlog_start_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
# Bug#7853 (mysqlbinlog does not accept input from stdin)
--disable_query_log
select "--- Test 6 reading stdin --" as "";
--enable_query_log
let $MYSQLD_DATADIR= `select @@datadir;`;
--echo --- Test 6 reading stdin --
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--exec $MYSQL_BINLOG --short-form --stop-position=$stop_position1 - < $MYSQLD_DATADIR/master-bin.000001
--disable_query_log
select "--- Test 7 reading stdin w/position --" as "";
--enable_query_log
--echo --- Test 7 reading stdin w/position --
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--exec $MYSQL_BINLOG --short-form --start-position=$position --stop-position=$stop_position - < $MYSQLD_DATADIR/master-bin.000001
# Bug#16217 (mysql client did not know how not switch its internal charset)
--disable_query_log
select "--- Test 8 switch internal charset --" as "";
--enable_query_log
--echo --- Test 8 switch internal charset --
sync_slave_with_master;
#we expect STOP SLAVE to produce a warning as the slave is stopped
#(the server was started with skip-slave-start)
--disable_warnings
stop slave;
--source include/wait_for_slave_to_stop.inc
--enable_warnings
connection master;
reset master;
connection slave;
@ -297,7 +240,6 @@ create table t4 (f text character set utf8);
create table t5 (f text character set cp932);
--exec $MYSQL --default-character-set=utf8 test -e "insert into t4 values(_utf8'ソ')"
--exec $MYSQL --default-character-set=cp932 test -e "insert into t5 values(_cp932'ƒ\');"
let $MYSQLD_DATADIR= `select @@datadir;`;
flush logs;
rename table t4 to t04, t5 to t05;
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 | $MYSQL --default-character-set=utf8
@ -314,42 +256,30 @@ select HEX(f) from t4;
select HEX(f) from t05;
select HEX(f) from t5;
--disable_query_log
select "--- Test cleanup --" as "";
--enable_query_log
--echo --- Test cleanup --
# clean up
connection master;
sync_slave_with_master;
connection master;
DROP TABLE t1, t2, t3, t04, t05, t4, t5;
# BUG#17654 also test mysqlbinlog to ensure it can read the binlog from a remote server
# and ensure that the results are the same as if read from a file (the same file).
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (a INT NOT NULL KEY, b INT);
INSERT INTO t1 VALUES(1,1);
SELECT * FROM t1;
let $MYSQLD_DATADIR= `select @@datadir;`;
FLUSH LOGS;
--exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 > $MYSQLTEST_VARDIR/tmp/remote.sql
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/local.sql
--diff_files $MYSQLTEST_VARDIR/tmp/local.sql $MYSQLTEST_VARDIR/tmp/remote.sql
--remove_file $MYSQLTEST_VARDIR/tmp/remote.sql
--remove_file $MYSQLTEST_VARDIR/tmp/local.sql
DROP TABLE t1;
DROP TABLE IF EXISTS t1, t2, t3, t04, t05, t4, t5;
sync_slave_with_master;
# End of 4.1 tests

View file

@ -33,5 +33,9 @@ SET @@GLOBAL.replicate_do_db="";
SELECT @@GLOBAL.replicate_do_db;
@@GLOBAL.replicate_do_db
SET @@GLOBAL.replicate_do_db=null;
SELECT @@GLOBAL.replicate_do_db;
@@GLOBAL.replicate_do_db
# Cleanup.
SET @@GLOBAL.replicate_do_db = @save_replicate_do_db;

View file

@ -40,5 +40,9 @@ SET @@GLOBAL.replicate_do_table="";
SELECT @@GLOBAL.replicate_do_table;
@@GLOBAL.replicate_do_table
SET @@GLOBAL.replicate_do_table=null;
SELECT @@GLOBAL.replicate_do_table;
@@GLOBAL.replicate_do_table
# Cleanup.
SET @@GLOBAL.replicate_do_table = @save_replicate_do_table;

View file

@ -33,5 +33,9 @@ SET @@GLOBAL.replicate_ignore_db="";
SELECT @@GLOBAL.replicate_ignore_db;
@@GLOBAL.replicate_ignore_db
SET @@GLOBAL.replicate_ignore_db=null;
SELECT @@GLOBAL.replicate_ignore_db;
@@GLOBAL.replicate_ignore_db
# Cleanup.
SET @@GLOBAL.replicate_ignore_db = @save_replicate_ignore_db;

View file

@ -40,5 +40,9 @@ SET @@GLOBAL.replicate_ignore_table="";
SELECT @@GLOBAL.replicate_ignore_table;
@@GLOBAL.replicate_ignore_table
SET @@GLOBAL.replicate_ignore_table=null;
SELECT @@GLOBAL.replicate_ignore_table;
@@GLOBAL.replicate_ignore_table
# Cleanup.
SET @@GLOBAL.replicate_ignore_table = @save_replicate_ignore_table;

View file

@ -40,5 +40,9 @@ SET @@GLOBAL.replicate_wild_do_table="";
SELECT @@GLOBAL.replicate_wild_do_table;
@@GLOBAL.replicate_wild_do_table
SET @@GLOBAL.replicate_wild_do_table=null;
SELECT @@GLOBAL.replicate_wild_do_table;
@@GLOBAL.replicate_wild_do_table
# Cleanup.
SET @@GLOBAL.replicate_wild_do_table = @save_replicate_wild_do_table;

View file

@ -40,5 +40,9 @@ SET @@GLOBAL.replicate_wild_ignore_table="";
SELECT @@GLOBAL.replicate_wild_ignore_table;
@@GLOBAL.replicate_wild_ignore_table
SET @@GLOBAL.replicate_wild_ignore_table=null;
SELECT @@GLOBAL.replicate_wild_ignore_table;
@@GLOBAL.replicate_wild_ignore_table
# Cleanup.
SET @@GLOBAL.replicate_wild_ignore_table = @save_replicate_wild_ignore_table;

View file

@ -35,5 +35,8 @@ SELECT @@GLOBAL.replicate_do_db;
SET @@GLOBAL.replicate_do_db="";
SELECT @@GLOBAL.replicate_do_db;
SET @@GLOBAL.replicate_do_db=null;
SELECT @@GLOBAL.replicate_do_db;
--echo # Cleanup.
SET @@GLOBAL.replicate_do_db = @save_replicate_do_db;

View file

@ -44,5 +44,8 @@ SELECT @@GLOBAL.replicate_do_table;
SET @@GLOBAL.replicate_do_table="";
SELECT @@GLOBAL.replicate_do_table;
SET @@GLOBAL.replicate_do_table=null;
SELECT @@GLOBAL.replicate_do_table;
--echo # Cleanup.
SET @@GLOBAL.replicate_do_table = @save_replicate_do_table;

View file

@ -35,5 +35,8 @@ SELECT @@GLOBAL.replicate_ignore_db;
SET @@GLOBAL.replicate_ignore_db="";
SELECT @@GLOBAL.replicate_ignore_db;
SET @@GLOBAL.replicate_ignore_db=null;
SELECT @@GLOBAL.replicate_ignore_db;
--echo # Cleanup.
SET @@GLOBAL.replicate_ignore_db = @save_replicate_ignore_db;

View file

@ -44,5 +44,8 @@ SELECT @@GLOBAL.replicate_ignore_table;
SET @@GLOBAL.replicate_ignore_table="";
SELECT @@GLOBAL.replicate_ignore_table;
SET @@GLOBAL.replicate_ignore_table=null;
SELECT @@GLOBAL.replicate_ignore_table;
--echo # Cleanup.
SET @@GLOBAL.replicate_ignore_table = @save_replicate_ignore_table;

View file

@ -44,5 +44,8 @@ SELECT @@GLOBAL.replicate_wild_do_table;
SET @@GLOBAL.replicate_wild_do_table="";
SELECT @@GLOBAL.replicate_wild_do_table;
SET @@GLOBAL.replicate_wild_do_table=null;
SELECT @@GLOBAL.replicate_wild_do_table;
--echo # Cleanup.
SET @@GLOBAL.replicate_wild_do_table = @save_replicate_wild_do_table;

View file

@ -44,5 +44,8 @@ SELECT @@GLOBAL.replicate_wild_ignore_table;
SET @@GLOBAL.replicate_wild_ignore_table="";
SELECT @@GLOBAL.replicate_wild_ignore_table;
SET @@GLOBAL.replicate_wild_ignore_table=null;
SELECT @@GLOBAL.replicate_wild_ignore_table;
--echo # Cleanup.
SET @@GLOBAL.replicate_wild_ignore_table = @save_replicate_wild_ignore_table;

View file

@ -2081,4 +2081,13 @@ DELIMITER ;|
create table t1 as select f1();
drop function f1;
--echo #
--echo # MDEV-10274 Bundling insert with create statement
--echo # for table with unsigned Decimal primary key issues warning 1194
--echo #
create table t1(ID decimal(2,1) unsigned NOT NULL, PRIMARY KEY (ID))engine=memory
select 2.1 ID;
drop table t1;
--echo End of 5.5 tests

View file

@ -1681,6 +1681,20 @@ SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65535) AS data) AS sub;
SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65536) AS data) AS sub;
SELECT length(data) AS len FROM (SELECT REPEAT('ä', 65537) AS data) AS sub;
--echo #
--echo # MDEV-10717 Assertion `!null_value' failed in virtual bool Item::send(Protocol*, String*)
--echo #
CREATE TABLE t1 (i INT, KEY(i));
INSERT INTO t1 VALUES (20081205),(20050327);
SELECT HEX(i), HEX(CHAR(i USING utf8)) FROM t1;
SET sql_mode='STRICT_ALL_TABLES';
SELECT HEX(i), HEX(CHAR(i USING utf8)) FROM t1;
# Avoid garbage in the output
--replace_column 1 ###
SELECT CHAR(i USING utf8) FROM t1;
SET sql_mode=DEFAULT;
DROP TABLE t1;
--echo #
--echo # End of 5.5 tests
--echo #

View file

@ -796,3 +796,50 @@ A.DIVISION=C1.DIVISION AND A.RECEIVABLE_GROUP=C1.RECEIVABLE_GROUP AND A.CREDIT_L
ORDER BY TOTAL DESC;
DROP TABLES t1,t2;
--echo #
--echo # MDEV-10663: Use of Inline table columns in HAVING clause
--echo # throws 1463 Error
--echo #
set @save_sql_mode = @@sql_mode;
set sql_mode='ONLY_FULL_GROUP_BY,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
CREATE TABLE `example1463` (
`Customer` varchar(255) NOT NULL,
`DeliveryStatus` varchar(255) NOT NULL,
`OrderSize` int(11) NOT NULL
);
INSERT INTO example1463 VALUES ('Charlie', 'Success', 100);
INSERT INTO example1463 VALUES ('David', 'Success', 110);
INSERT INTO example1463 VALUES ('Charlie', 'Failed', 200);
INSERT INTO example1463 VALUES ('David', 'Success', 100);
INSERT INTO example1463 VALUES ('David', 'Unknown', 100);
INSERT INTO example1463 VALUES ('Edward', 'Success', 150);
INSERT INTO example1463 VALUES ('Edward', 'Pending', 150);
SELECT Customer, Success, SUM(OrderSize)
FROM (SELECT Customer,
CASE WHEN DeliveryStatus='Success' THEN 'Yes' ELSE 'No' END AS Success,
OrderSize
FROM example1463) as subQ
GROUP BY Success, Customer
WITH ROLLUP;
SELECT Customer, Success, SUM(OrderSize)
FROM (SELECT Customer,
CASE WHEN DeliveryStatus='Success' THEN 'Yes' ELSE 'No' END AS Success,
OrderSize
FROM example1463) as subQ
GROUP BY Success, Customer;
SELECT Customer, Success, SUM(OrderSize)
FROM (SELECT Customer,
CASE WHEN DeliveryStatus='Success' THEN 'Yes' ELSE 'No' END AS Success,
OrderSize
FROM example1463) as subQ
GROUP BY Success, Customer
HAVING Success IS NOT NULL;
DROP TABLE example1463;
set sql_mode= @save_sql_mode;
--echo # end of 5.5

View file

@ -1827,6 +1827,60 @@ DROP TABLE t1,t2;
--echo # end of 5.3 tests
--echo #
--echo #
--echo # Bug mdev-11161: The second execution of prepared statement
--echo # does not use generated key for materialized
--echo # derived table / view
--echo # (actually this is a 5.3 bug.)
--echo #
create table t1 (
mat_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
matintnum CHAR(6) NOT NULL,
test MEDIUMINT UNSIGNED NULL
);
create table t2 (
mat_id MEDIUMINT UNSIGNED NOT NULL,
pla_id MEDIUMINT UNSIGNED NOT NULL
);
insert into t1 values
(NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd', 4),
(NULL, 'e', 5), (NULL, 'f', 6), (NULL, 'g', 7), (NULL, 'h', 8),
(NULL, 'i', 9);
insert into t2 values
(1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104),
(3, 101), (3, 102), (3, 105);
explain
SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id
FROM t1 m2
INNER JOIN
(SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum
FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id
GROUP BY mp.pla_id) d
ON d.matintnum=m2.matintnum;
prepare stmt1 from
"SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id
FROM t1 m2
INNER JOIN
(SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum
FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id
GROUP BY mp.pla_id) d
ON d.matintnum=m2.matintnum";
flush status;
execute stmt1;
show status like '%Handler_read%';
flush status;
execute stmt1;
show status like '%Handler_read%';
deallocate prepare stmt1;
drop table t1,t2;
# The following command must be the last one the file
set optimizer_switch=@exit_optimizer_switch;
set join_cache_level=@exit_join_cache_level;

View file

@ -0,0 +1,28 @@
--source include/not_embedded.inc
#
# MDEV-11552 Queries executed by event scheduler are written to slow log incorrectly or not written at all
#
set @event_scheduler_save= @@global.event_scheduler;
set @slow_query_log_save= @@global.slow_query_log;
set global event_scheduler= on;
set global slow_query_log= on;
set global long_query_time=0.2;
create table t1 (i int);
insert into t1 values (0);
create event ev on schedule at CURRENT_TIMESTAMP + INTERVAL 1 second do update t1 set i=1+sleep(0.5);
--let wait_condition= select i from t1 where i > 0
--source include/wait_condition.inc
--let SEARCH_FILE = `SELECT @@slow_query_log_file`
--let SEARCH_PATTERN= update t1 set i=1
--let SEARCH_RANGE= -1000
--source include/search_pattern_in_file.inc
drop table t1;
set global event_scheduler= @event_scheduler_save;
set global slow_query_log= @slow_query_log_save;
set global long_query_time= @@session.long_query_time;

View file

@ -0,0 +1,10 @@
#
# MDEV-11241 Certain combining marks cause MariaDB to crash when doing Full-Text searches
#
set names utf8mb4;
create table t1 (a int, b text, fulltext (b)) charset=utf8mb4 collate=utf8mb4_unicode_ci;
insert t1 values (1000, 'C͓̙̯͔̩ͅͅi̩̘̜̲a̯̲̬̳̜̖̤o͕͓̜͓̺̖̗,̠̬͚ ̺T͇̲h͈̱e ̬̜D̖o̦̖͔̗͖̩̘c̣̼t̝͉̫̮̗o͉̫̭r̙͎̗.͓̪̥');
select a from t1 where match(b) against ('ciao' in boolean mode);
drop table t1;

View file

@ -1597,3 +1597,8 @@ INSERT INTO t1 VALUES (17, NULL);
INSERT INTO t1 VALUES (18, '2010-10-13');
SELECT a.id,a.date1,FROM_DAYS(TO_DAYS(a.date1)-10) as date2, DATE_ADD(a.date1,INTERVAL -10 DAY),TO_DAYS(a.date1)-10 FROM t1 a ORDER BY a.id;
DROP TABLE t1;
--echo #
--echo # MDEV-10524 Assertion `arg1_int >= 0' failed in Item_func_additive_op::result_precision()
--echo #
SELECT 1 MOD ADDTIME( '13:58:57', '00:00:01' ) + 2;

View file

@ -1691,6 +1691,18 @@ SELECT MAX(i), c FROM t1
WHERE c != 'qux' AND ( SELECT SUM(j) FROM t1, t2 ) IS NOT NULL GROUP BY c;
drop table t1,t2;
--echo #
--echo # ONLY_FULL_GROUP_BY references
--echo #
set @save_sql_mode = @@sql_mode;
set sql_mode='ONLY_FULL_GROUP_BY';
create table t1 (a int, b int);
select a+b as x from t1 group by x having x > 1;
select a as x from t1 group by x having x > 1;
select a from t1 group by a having a > 1;
drop table t1;
set sql_mode= @save_sql_mode;
#
# End of MariaDB 5.5 tests
#

View file

@ -171,6 +171,37 @@ WHERE ( tb.b != ta.b OR tb.a = ta.a )
AND ( tb.b = ta.c OR tb.b = ta.b );
DROP TABLE t1;
set optimizer_switch= @optimizer_switch_save;
--echo #
--echo # MDEV-10927: Crash When Using sort_union Optimization
--echo #
set @tmp_optimizer_switch=@@optimizer_switch;
SET optimizer_switch='index_merge_sort_intersection=on';
SET SESSION sort_buffer_size = 1024;
create table t1 (
pk int(11) NOT NULL AUTO_INCREMENT,
col1 int(11) NOT NULL,
col2 int(11) NOT NULL,
col3 int(11) NOT NULL,
key2 int(11) NOT NULL,
col4 int(11) NOT NULL,
key1 int(11) NOT NULL,
PRIMARY KEY (pk),
KEY key1 (key1),
KEY key2 (key2)
) ENGINE=InnoDB AUTO_INCREMENT=12860259 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
create table t2(a int);
insert into t2 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t3(a int);
insert into t3 select A.a + B.a* 10 + C.a * 100 + D.a*1000 from t2 A, t2 B, t2 C, t2 D;
insert into t1 (key1, key2, col1,col2,col3,col4)
select a,a, a,a,a,a from t3;
SELECT sum(col1) FROM t1 FORCE INDEX (key1,key2) WHERE (key1 between 10 and 8191+10) or (key2= 5);
drop table t1,t2,t3;
set optimizer_switch=@tmp_optimizer_switch;

View file

@ -612,13 +612,13 @@ select * from information_schema.schema_privileges order by grantee;
select * from information_schema.user_privileges order by grantee;
show grants;
connection con4;
select * from information_schema.column_privileges where grantee like '%user%'
select * from information_schema.column_privileges where grantee like '\'user%'
order by grantee;
select * from information_schema.table_privileges where grantee like '%user%'
select * from information_schema.table_privileges where grantee like '\'user%'
order by grantee;
select * from information_schema.schema_privileges where grantee like '%user%'
select * from information_schema.schema_privileges where grantee like '\'user%'
order by grantee;
select * from information_schema.user_privileges where grantee like '%user%'
select * from information_schema.user_privileges where grantee like '\'user%'
order by grantee;
show grants;
connection default;

View file

@ -131,3 +131,10 @@ drop table if exists t1;
create table t1 (f1 int key) partition by key(f1) partitions 2;
select create_options from information_schema.tables where table_schema="test";
drop table t1;
--echo #
--echo # MDEV-11353 - Identical logical conditions
--echo #
CREATE TABLE t1(a INT) CHECKSUM=1 SELECT 1;
SELECT CHECKSUM FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
DROP TABLE t1;

View file

@ -612,7 +612,7 @@ disconnect con1;
--echo #
CREATE TABLE t1(f1 INT);
EVAL SELECT 0xE1C330 INTO OUTFILE 't1.dat';
EVAL SELECT 0xE1BB30 INTO OUTFILE 't1.dat';
--disable_warnings
LOAD DATA INFILE 't1.dat' IGNORE INTO TABLE t1 CHARACTER SET utf8;
--enable_warnings
@ -658,26 +658,3 @@ SET @@sql_mode= @old_mode;
--remove_file $MYSQLTEST_VARDIR/mysql
DROP TABLE t1;
--echo
--echo #
--echo # Bug#23080148 - Backport of Bug#20683959.
--echo # Bug#20683959 LOAD DATA INFILE IGNORES A SPECIFIC ROW SILENTLY
--echo # UNDER DB CHARSET IS UTF8.
--echo #
CREATE DATABASE d1 CHARSET latin1;
USE d1;
CREATE TABLE t1 (val TEXT);
LOAD DATA INFILE '../../std_data/bug20683959loaddata.txt' INTO TABLE t1;
SELECT COUNT(*) FROM t1;
SELECT HEX(val) FROM t1;
CREATE DATABASE d2 CHARSET utf8;
USE d2;
CREATE TABLE t1 (val TEXT);
--error ER_INVALID_CHARACTER_STRING
LOAD DATA INFILE '../../std_data/bug20683959loaddata.txt' INTO TABLE t1;
DROP TABLE d1.t1, d2.t1;
DROP DATABASE d1;
DROP DATABASE d2;

View file

@ -770,3 +770,13 @@ select 2>!0, 2 > ! 0;
select 0<=!0, 0 <= !0;
select 1<<!0, 1 << !0;
select 0<!0, 0 < ! 0;
--echo #
--echo # MDEV-11171 Assertion `m_cpp_buf <= ptr && ptr <= m_cpp_buf + m_buf_length' failed in Lex_input_stream::body_utf8_append(const char*, const char*)
--echo #
CREATE TABLE t1 (id INT);
--error ER_PARSE_ERROR
CREATE TRIGGER tr AFTER DELETE ON t1 FOR EACH ROW SET @a = 1\;
--error ER_PARSE_ERROR
PREPARE stmt FROM 'CREATE TRIGGER tr AFTER DELETE ON t1 FOR EACH ROW SET @a = 1\\';
DROP TABLE t1;

View file

@ -9302,4 +9302,55 @@ CALL p1;
DROP PROCEDURE p1;
DROP TABLE t1;
--echo #
--echo # MDEV-10713: signal 11 error on multi-table update - crash in
--echo # handler::increment_statistics or in make_select or assertion
--echo # failure pfs_thread == ((PFS_thread*) pthread_getspecific((THR_PFS)))
--echo #
CREATE TABLE `t1` (
`CLOSE_YN` varchar(10) COLLATE utf8_bin DEFAULT NULL
) DEFAULT CHARSET=utf8 COLLATE=utf8_bin ;
CREATE TABLE `t2` (
`ap_close_to` varchar(8) COLLATE utf8_bin DEFAULT NULL
) DEFAULT CHARSET=utf8 COLLATE=utf8_bin ;
insert t1 values (1);
--delimiter $$
CREATE FUNCTION `f1`(`P_DC_CD` VARBINARY(50), `P_SYS_DATE` DATETIME) RETURNS datetime
DETERMINISTIC
SQL SECURITY INVOKER
BEGIN
DECLARE V_SYS_DATE DATETIME;
SELECT now() AS LOC_DATE INTO V_SYS_DATE ;
RETURN v_sys_date ;
END $$
--delimiter ;
update t1 S
JOIN
(
SELECT CASE
WHEN DATE_FORMAT( f1('F01', NOW()) , '%Y%m%d') <= CLOSE_YMD
THEN '99991231'
ELSE '' END ACCOUNT_APPLY_YYYYMMDD
FROM (
select case
when 'AP'='AP'
then ap_close_to
end AS CLOSE_YMD
from t2
) A
) X
SET S.CLOSE_YN = ''
where 1=1;
drop function if exists f1;
drop table t1,t2;
--echo # End of 5.5 test

View file

@ -5974,3 +5974,27 @@ INSERT INTO t1 VALUES(0),(0),(0);
SELECT * FROM t1 WHERE a IN(SELECT MIN(a) FROM t1);
DROP TABLE t1;
SET SESSION big_tables=0;
--echo #
--echo # MDEV-10776: Server crash on query
--echo #
create table t1 (field1 int);
insert into t1 values (1);
select round((select 1 from t1 limit 1))
from t1
group by round((select 1 from t1 limit 1));
drop table t1;
--echo #
--echo # MDEV-10386 Assertion `fixed == 1' failed in virtual String* Item_func_conv_charset::val_str(String*)
--echo #
CREATE TABLE t1 (f1 CHAR(3) CHARACTER SET utf8 NULL, f2 CHAR(3) CHARACTER SET latin1 NULL);
INSERT INTO t1 VALUES ('foo','bar');
SELECT * FROM t1 WHERE f2 >= SOME ( SELECT f1 FROM t1 );
SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
DROP TABLE t1;

View file

@ -359,5 +359,55 @@ where t1.a = t2.a and ( t1.a = ( select min(a) from t1 ) or 0 );
drop table t1,t2,t3;
--echo #
--echo # MDEV-10148: Database crashes in the query to the View
--echo #
CREATE TABLE t1 (
key_code INT(11) NOT NULL,
value_string VARCHAR(50) NULL DEFAULT NULL,
PRIMARY KEY (key_code)
) COLLATE='utf8_general_ci' ENGINE=InnoDB ;
CREATE TABLE t2 (
key_code INT(11) NOT NULL,
target_date DATE NULL DEFAULT NULL,
PRIMARY KEY (key_code)
) COLLATE='utf8_general_ci' ENGINE=InnoDB ;
CREATE TABLE t3 (
now_date DATE NOT NULL,
PRIMARY KEY (now_date)
) COLLATE='utf8_general_ci' ENGINE=InnoDB ;
CREATE VIEW v1
AS
SELECT
B.key_code,
B.target_date
FROM
t2 B INNER JOIN t3 C ON
B.target_date = C.now_date
;
SET @s = 'SELECT A.* FROM t1 A WHERE A.key_code IN (SELECT key_code FROM v1)';
PREPARE stmt FROM @s;
EXECUTE stmt; #1st time -> success
EXECUTE stmt; #2nd time -> crash
DEALLOCATE PREPARE stmt;
DROP VIEW v1;
DROP TABLE t1,t2,t3;
set optimizer_switch=@subselect2_test_tmp;
#
# Bug #23303485 : HANDLE_FATAL_SIGNAL (SIG=11) IN SUBSELECT_UNION_ENGINE::NO_ROWS
#
create table t1 (a int);
create table t2 (a int);
create table t3(a int);
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
insert into t2 select a from t1;
insert into t3 select a from t1;
--error ER_SUBQUERY_NO_1_ROW
select null in (select a from t1 where a < out3.a union select a from t2 where
(select a from t3) +1 < out3.a+1) from t3 out3;
drop table t1, t2, t3;

View file

@ -1959,5 +1959,46 @@ SELECT x FROM t1 WHERE id > (SELECT MAX(id) - 1000 FROM t1) ORDER BY x LIMIT 1;
drop table t1;
--echo #
--echo # MDEV-7691: Assertion `outer_context || !*from_field || *from_field == not_found_field' ...
--echo #
set optimizer_switch=default;
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (4),(6);
CREATE TABLE t2 (b INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1),(8);
PREPARE stmt FROM "
SELECT * FROM t2
HAVING 0 IN (
SELECT a FROM t1
WHERE a IN (
SELECT a FROM t1
WHERE b = a
)
)
";
EXECUTE stmt;
EXECUTE stmt;
--echo # Alternative test case, without HAVING
CREATE TABLE t3 (i INT) ENGINE=MyISAM;
INSERT INTO t3 VALUES (4),(6);
PREPARE stmt FROM "
SELECT * FROM t3 AS t10
WHERE EXISTS (
SELECT * FROM t3 AS t20 WHERE t10.i IN (
SELECT i FROM t3
)
)";
EXECUTE stmt;
EXECUTE stmt;
drop table t1, t2, t3;
SET optimizer_switch= @@global.optimizer_switch;
set @@tmp_table_size= @@global.tmp_table_size;

View file

@ -604,6 +604,11 @@ SHOW COLUMNS FROM t1dec102;
SELECT COLUMN_NAME, DATA_TYPE, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='t1dec102';
DROP TABLE t1dec102;
#
# MDEV-10552 equality operation on cast of the value "-0.0" to decimal not working
#
select cast('-0.0' as decimal(5,1)) < 0;
--echo #
--echo # End of 5.5 tests
--echo #

View file

@ -1022,7 +1022,6 @@ ORDER BY a;
DROP TABLE t1;
--echo End of 5.0 tests
-- echo #
-- echo # Bug#32858: Error: "Incorrect usage of UNION and INTO" does not take
-- echo # subselects into account
@ -1126,6 +1125,8 @@ create table t1 (a int);
insert into t1 values (10),(10),(10),(2),(3),(4),(5),(6),(7),(8),(9),(1),(10);
--sorted_result
select a from t1 where false UNION select a from t1 limit 8;
--sorted_result
(select a from t1 where false) UNION (select a from t1) limit 8;
drop table t1;
--echo #
@ -1350,3 +1351,22 @@ UNION
;
drop table t1;
--echo #
--echo # MDEV-10172: UNION query returns incorrect rows outside
--echo # conditional evaluation
--echo #
create table t1 (d datetime not null primary key);
insert into t1(d) values ('2016-06-01'),('2016-06-02'),('2016-06-03'),('2016-06-04');
select * from
(
select * from t1 where d between '2016-06-02' and '2016-06-05'
union
(select * from t1 where d < '2016-06-05' order by d desc limit 1)
) onlyJun2toJun4
order by d;
drop table t1;
--echo End of 5.0 tests

View file

@ -34,7 +34,7 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c
rijndael.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c
thr_rwlock.c tree.c typelib.c base64.c my_memmem.c my_getpagesize.c
lf_alloc-pin.c lf_dynarray.c lf_hash.c
safemalloc.c my_new.cc
safemalloc.c my_new.cc
my_atomic.c my_getncpus.c my_safehash.c my_chmod.c my_rnd.c
my_uuid.c wqueue.c waiting_threads.c ma_dyncol.c
my_rdtsc.c my_context.c file_logger.c)
@ -44,7 +44,7 @@ IF (WIN32)
ENDIF()
IF(UNIX)
SET (MYSYS_SOURCES ${MYSYS_SOURCES} my_addr_resolve.c)
SET (MYSYS_SOURCES ${MYSYS_SOURCES} my_addr_resolve.c my_setuser.c)
ENDIF()
IF(HAVE_ALARM)

81
mysys/my_setuser.c Normal file
View file

@ -0,0 +1,81 @@
#include <my_global.h>
#include <m_string.h>
#include <my_sys.h>
#include <my_pthread.h>
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#ifdef HAVE_GRP_H
#include <grp.h>
#endif
struct passwd *my_check_user(const char *user, myf MyFlags)
{
struct passwd *user_info;
uid_t user_id= geteuid();
DBUG_ENTER("my_check_user");
// Don't bother if we aren't superuser
if (user_id)
{
if (user)
{
/* Don't give a warning, if real user is same as given with --user */
user_info= getpwnam(user);
if (!user_info || user_id != user_info->pw_uid)
{
my_errno= EPERM;
if (MyFlags & MY_WME)
my_printf_error(my_errno, "One can only use the --user switch if "
"running as root", MYF(ME_JUST_WARNING|ME_NOREFRESH));
}
}
DBUG_RETURN(NULL);
}
if (!user)
{
if (MyFlags & MY_FAE)
{
my_errno= EINVAL;
my_printf_error(my_errno, "Please consult the Knowledge Base to find "
"out how to run mysqld as root!", MYF(ME_NOREFRESH));
}
DBUG_RETURN(NULL);
}
if (!strcmp(user,"root"))
DBUG_RETURN(NULL);
if (!(user_info= getpwnam(user)))
{
// Allow a numeric uid to be used
int err= 0;
user_id= my_strtoll10(user, NULL, &err);
if (err || !(user_info= getpwuid(user_id)))
{
my_errno= EINVAL;
my_printf_error(my_errno, "Can't change to run as user '%s'. Please "
"check that the user exists!", MYF(ME_NOREFRESH), user);
DBUG_RETURN(NULL);
}
}
DBUG_ASSERT(user_info);
DBUG_RETURN(user_info);
}
int my_set_user(const char *user, struct passwd *user_info, myf MyFlags)
{
DBUG_ENTER("my_set_user");
DBUG_ASSERT(user_info != 0);
#ifdef HAVE_INITGROUPS
initgroups(user, user_info->pw_gid);
#endif
if (setgid(user_info->pw_gid) == -1 || setuid(user_info->pw_uid) == -1)
{
my_errno= errno;
if (MyFlags & MY_WME)
my_error(my_errno, MYF(ME_NOREFRESH));
DBUG_RETURN(my_errno);
}
DBUG_RETURN(0);
}

View file

@ -2845,6 +2845,7 @@ void __attribute__ ((constructor)) audit_plugin_so_init(void)
_mysql_plugin_declarations_[0].info= mysql_v4_descriptor;
use_event_data_for_disconnect= 1;
}
MYSQL_SYSVAR_NAME(loc_info).flags= PLUGIN_VAR_READONLY | PLUGIN_VAR_MEMALLOC;
}
memset(locinfo_ini_value, 'O', sizeof(locinfo_ini_value)-1);

View file

@ -512,10 +512,8 @@ then
echo "The latest information about MariaDB is available at http://mariadb.org/."
echo "You can find additional information about the MySQL part at:"
echo "http://dev.mysql.com"
echo "Support MariaDB development by buying support/new features from MariaDB"
echo "Corporation Ab. You can contact us about this at sales@mariadb.com."
echo "Alternatively consider joining our community based development effort:"
echo "http://mariadb.com/kb/en/contributing-to-the-mariadb-project/"
echo "Consider joining MariaDB's strong and vibrant community:"
echo "https://mariadb.org/get-involved/"
echo
fi

View file

@ -20,6 +20,7 @@ mysqld_ld_preload=
mysqld_ld_library_path=
flush_caches=0
numa_interleave=0
unsafe_my_cnf=0
# Initial logging status: error log is not open, and not using syslog
logging=init
@ -128,6 +129,18 @@ my_which ()
return $ret # Success
}
find_in_bin() {
if test -x "$MY_BASEDIR_VERSION/bin/$1"
then
echo "$MY_BASEDIR_VERSION/bin/$1"
elif test -x "@bindir@/$1"
then
echo "@bindir@/$1"
else
echo "$1"
fi
}
log_generic () {
priority="$1"
shift
@ -136,7 +149,7 @@ log_generic () {
echo "$msg"
case $logging in
init) ;; # Just echo the message, don't save it anywhere
file) echo "$msg" >> "$err_log" ;;
file) echo "$msg" | "$helper" "$user" log "$err_log" ;;
syslog) logger -t "$syslog_tag_mysqld_safe" -p "$priority" "$*" ;;
*)
echo "Internal program error (non-fatal):" \
@ -156,7 +169,7 @@ log_notice () {
eval_log_error () {
local cmd="$1"
case $logging in
file) cmd="$cmd >> "`shell_quote_string "$err_log"`" 2>&1" ;;
file) cmd="$cmd 2>&1 | "`shell_quote_string "$helper"`" $user log "`shell_quote_string "$err_log"` ;;
syslog)
# mysqld often prefixes its messages with a timestamp, which is
# redundant when logging to syslog (which adds its own timestamp)
@ -274,6 +287,13 @@ wsrep_recover_position() {
return $ret
}
check_executable_location() {
if test "$unsafe_my_cnf" = 1 -a "$unrecognized_handling" != collect; then
log_error "Cannot accept $1 from a config file, when my.cnf is in the datadir"
exit 1
fi
}
parse_arguments() {
for arg do
# the parameter after "=", or the whole $arg if no match
@ -284,7 +304,6 @@ parse_arguments() {
optname_subst=`echo "$optname" | sed 's/_/-/g'`
arg=`echo $arg | sed "s/^$optname/$optname_subst/"`
case "$arg" in
--crash-script=*) CRASH_SCRIPT="$val" ;;
# these get passed explicitly to mysqld
--basedir=*) MY_BASEDIR_VERSION="$val" ;;
--datadir=*|--data=*) DATADIR="$val" ;;
@ -304,12 +323,14 @@ parse_arguments() {
# mysqld_safe-specific options - must be set in my.cnf ([mysqld_safe])!
--core-file-size=*) core_file_size="$val" ;;
--ledir=*) ledir="$val" ;;
--malloc-lib=*) set_malloc_lib "$val" ;;
--mysqld=*) MYSQLD="$val" ;;
--ledir=*) check_executable_location "$arg" ; ledir="$val" ;;
--malloc-lib=*) check_executable_location "$arg"; set_malloc_lib "$val" ;;
--crash-script=*) check_executable_location "$arg"; crash_script="$val" ;;
--mysqld=*) check_executable_location "$arg"; MYSQLD="$val" ;;
--mysqld-version=*)
if test -n "$val"
then
check_executable_location "$arg"
MYSQLD="mysqld-$val"
PLUGIN_VARIANT="/$val"
else
@ -476,15 +497,8 @@ set_malloc_lib() {
# First, try to find BASEDIR and ledir (where mysqld is)
#
if echo '@pkgdatadir@' | grep '^@prefix@' > /dev/null
then
relpkgdata=`echo '@pkgdatadir@' | sed -e 's,^@prefix@,,' -e 's,^/,,' -e 's,^,./,'`
else
# pkgdatadir is not relative to prefix
relpkgdata='@pkgdatadir@'
fi
MY_PWD=`pwd`
MY_PWD=`dirname $0`
MY_PWD=`cd "$MY_PWD"/.. && pwd`
# Check for the directories we would expect from a binary release install
if test -n "$MY_BASEDIR_VERSION" -a -d "$MY_BASEDIR_VERSION"
then
@ -500,16 +514,16 @@ then
else
ledir="$MY_BASEDIR_VERSION/bin"
fi
elif test -f "$relpkgdata"/english/errmsg.sys -a -x "$MY_PWD/bin/mysqld"
elif test -x "$MY_PWD/bin/mysqld"
then
MY_BASEDIR_VERSION="$MY_PWD" # Where bin, share and data are
ledir="$MY_PWD/bin" # Where mysqld is
# Check for the directories we would expect from a source install
elif test -f "$relpkgdata"/english/errmsg.sys -a -x "$MY_PWD/libexec/mysqld"
elif test -x "$MY_PWD/libexec/mysqld"
then
MY_BASEDIR_VERSION="$MY_PWD" # Where libexec, share and var are
ledir="$MY_PWD/libexec" # Where mysqld is
elif test -f "$relpkgdata"/english/errmsg.sys -a -x "$MY_PWD/sbin/mysqld"
elif test -x "$MY_PWD/sbin/mysqld"
then
MY_BASEDIR_VERSION="$MY_PWD" # Where sbin, share and var are
ledir="$MY_PWD/sbin" # Where mysqld is
@ -519,6 +533,8 @@ else
ledir='@libexecdir@'
fi
helper=`find_in_bin mysqld_safe_helper`
print_defaults=`find_in_bin my_print_defaults`
#
# Second, try to find the data directory
@ -556,6 +572,7 @@ IGNORING $DATADIR/my.cnf"
log_error "WARNING: Found $DATADIR/my.cnf
The data directory is a deprecated location for my.cnf, please move it to
$MY_BASEDIR_VERSION/my.cnf"
unsafe_my_cnf=1
MYSQL_HOME=$DATADIR
else
MYSQL_HOME=$MY_BASEDIR_VERSION
@ -563,34 +580,15 @@ $MY_BASEDIR_VERSION/my.cnf"
fi
export MYSQL_HOME
# Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
# and then merge with the command line arguments
if test -x "$MY_BASEDIR_VERSION/bin/my_print_defaults"
then
print_defaults="$MY_BASEDIR_VERSION/bin/my_print_defaults"
elif test -x `dirname $0`/my_print_defaults
then
print_defaults="`dirname $0`/my_print_defaults"
elif test -x ./bin/my_print_defaults
then
print_defaults="./bin/my_print_defaults"
elif test -x @bindir@/my_print_defaults
then
print_defaults="@bindir@/my_print_defaults"
elif test -x @bindir@/mysql_print_defaults
then
print_defaults="@bindir@/mysql_print_defaults"
else
print_defaults="my_print_defaults"
fi
append_arg_to_args () {
args="$args "`shell_quote_string "$1"`
}
args=
# Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
# and then merge with the command line arguments
SET_USER=2
parse_arguments `$print_defaults $defaults --loose-verbose --mysqld`
if test $SET_USER -eq 2
@ -694,11 +692,6 @@ then
log_notice "Logging to '$err_log'."
logging=file
if [ ! -f "$err_log" ]; then # if error log already exists,
touch "$err_log" # we just append. otherwise,
chmod "$fmode" "$err_log" # fix the permissions here!
fi
else
if [ -n "$syslog_tag" ]
then
@ -711,10 +704,6 @@ else
logging=syslog
fi
# close stdout and stderr, everything goes to $logging now
exec 1>&-
exec 2>&-
USER_OPTION=""
if test -w / -o "$USER" = "root"
then
@ -722,11 +711,6 @@ then
then
USER_OPTION="--user=$user"
fi
# Change the err log to the right user, if it is in use
if [ $want_syslog -eq 0 ]; then
touch "$err_log"
chown $user "$err_log"
fi
if test -n "$open_files"
then
ulimit -n $open_files
@ -974,6 +958,10 @@ have_sleep=1
# maximum number of wsrep restarts
max_wsrep_restarts=0
# close stdout and stderr, everything goes to $logging now
exec 1>&-
exec 2>&-
while true
do
rm -f $safe_mysql_unix_port "$pid_file" # Some extra safety
@ -1000,6 +988,7 @@ do
chmod "$fmode" "$err_log" # wrong owner next time we log, so set
fi # it up correctly while we can!
eval_log_error "$cmd"
end_time=`date +%M%S`
if test ! -f "$pid_file" # This is removed if normal shutdown
@ -1077,9 +1066,9 @@ do
fi
log_notice "mysqld restarted"
if test -n "$CRASH_SCRIPT"
if test -n "$crash_script"
then
crash_script_output=`$CRASH_SCRIPT 2>&1`
crash_script_output=`$crash_script 2>&1`
log_error "$crash_script_output"
fi
done

View file

@ -17,6 +17,7 @@
#include "sql_priv.h"
#include "unireg.h"
#include "sql_base.h" // close_thread_tables
#include "sql_parse.h"
#include "event_db_repository.h"
#include "key.h" // key_copy
#include "sql_db.h" // get_default_db_collation
@ -702,19 +703,17 @@ Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data,
restore_record(table, s->default_values); // Get default values for fields
if (system_charset_info->cset->
numchars(system_charset_info, parse_data->dbname.str,
parse_data->dbname.str + parse_data->dbname.length) >
table->field[ET_FIELD_DB]->char_length())
if (check_string_char_length(&parse_data->dbname, 0,
table->field[ET_FIELD_DB]->char_length(),
system_charset_info, 1))
{
my_error(ER_TOO_LONG_IDENT, MYF(0), parse_data->dbname.str);
goto end;
}
if (system_charset_info->cset->
numchars(system_charset_info, parse_data->name.str,
parse_data->name.str + parse_data->name.length) >
table->field[ET_FIELD_NAME]->char_length())
if (check_string_char_length(&parse_data->name, 0,
table->field[ET_FIELD_NAME]->char_length(),
system_charset_info, 1))
{
my_error(ER_TOO_LONG_IDENT, MYF(0), parse_data->name.str);
goto end;

View file

@ -1157,12 +1157,15 @@ void Field_num::prepend_zeros(String *value)
int diff;
if ((diff= (int) (field_length - value->length())) > 0)
{
bmove_upp((uchar*) value->ptr()+field_length,
(uchar*) value->ptr()+value->length(),
value->length());
bfill((uchar*) value->ptr(),diff,'0');
value->length(field_length);
(void) value->c_ptr_quick(); // Avoid warnings in purify
const bool error= value->realloc(field_length);
if (!error)
{
bmove_upp((uchar*) value->ptr()+field_length,
(uchar*) value->ptr()+value->length(),
value->length());
bfill((uchar*) value->ptr(),diff,'0');
value->length(field_length);
}
}
}

View file

@ -1411,7 +1411,7 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file,
if (!(error= (int) read_to_buffer(from_file, buffpek,
rec_length)))
{
queue_remove(&queue,0);
(void) queue_remove_top(&queue);
reuse_freed_buff(&queue, buffpek, rec_length);
}
else if (error == -1)

View file

@ -3995,7 +3995,7 @@ void handler::get_dynamic_partition_info(PARTITION_STATS *stat_info,
stat_info->update_time= stats.update_time;
stat_info->check_time= stats.check_time;
stat_info->check_sum= 0;
if (table_flags() & (HA_HAS_OLD_CHECKSUM | HA_HAS_OLD_CHECKSUM))
if (table_flags() & (HA_HAS_OLD_CHECKSUM | HA_HAS_NEW_CHECKSUM))
stat_info->check_sum= checksum();
return;
}

View file

@ -1164,7 +1164,8 @@ Item *Item_cache::safe_charset_converter(CHARSET_INFO *tocs)
if (conv == example)
return this;
Item_cache *cache;
if (!conv || !(cache= new Item_cache_str(conv)))
if (!conv || conv->fix_fields(current_thd, (Item **) NULL) ||
!(cache= new Item_cache_str(conv)))
return NULL; // Safe conversion is not possible, or OEM
cache->setup(conv);
cache->fixed= false; // Make Item::fix_fields() happy
@ -2777,6 +2778,44 @@ void Item_field::fix_after_pullout(st_select_lex *new_parent, Item **ref)
depended_from= NULL;
if (context)
{
bool need_change= false;
/*
Suppose there are nested selects:
select_id=1
select_id=2
select_id=3 <----+
select_id=4 -+
select_id=5 --+
Suppose, pullout operation has moved anything that had select_id=4 or 5
in to select_id=3.
If this Item_field had a name resolution context pointing into select_lex
with id=4 or id=5, it needs a new name resolution context.
However, it could also be that this object is a part of outer reference:
Item_ref(Item_field(field in select with select_id=1))).
- The Item_ref object has a context with select_id=5, and so needs a new
name resolution context.
- The Item_field object has a context with select_id=1, and doesn't need
a new name resolution context.
So, the following loop walks from Item_field's current context upwards.
If we find that the select we've been pulled out to is up there, we
create the new name resolution context. Otherwise, we don't.
*/
for (Name_resolution_context *ct= context; ct; ct= ct->outer_context)
{
if (new_parent == ct->select_lex)
{
need_change= true;
break;
}
}
if (!need_change)
return;
Name_resolution_context *ctx= new Name_resolution_context();
if (context->select_lex == new_parent)
{
@ -4556,8 +4595,6 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
const char *field_name;
ORDER *found_group= NULL;
int found_match_degree= 0;
Item_ident *cur_field;
int cur_match_degree= 0;
char name_buff[SAFE_NAME_LEN+1];
if (find_item->type() == Item::FIELD_ITEM ||
@ -4582,54 +4619,70 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
for (ORDER *cur_group= group_list ; cur_group ; cur_group= cur_group->next)
{
if ((*(cur_group->item))->real_item()->type() == Item::FIELD_ITEM)
int cur_match_degree= 0;
/* SELECT list element with explicit alias */
if ((*(cur_group->item))->name &&
!(*(cur_group->item))->is_autogenerated_name &&
!my_strcasecmp(system_charset_info,
(*(cur_group->item))->name, field_name))
{
cur_field= (Item_ident*) *cur_group->item;
cur_match_degree= 0;
DBUG_ASSERT(cur_field->field_name != 0);
++cur_match_degree;
}
/* Reference on the field or view/derived field. */
else if ((*(cur_group->item))->type() == Item::FIELD_ITEM ||
(*(cur_group->item))->type() == Item::REF_ITEM )
{
Item_ident *cur_field= (Item_ident*) *cur_group->item;
const char *l_db_name= cur_field->db_name;
const char *l_table_name= cur_field->table_name;
const char *l_field_name= cur_field->field_name;
DBUG_ASSERT(l_field_name != 0);
if (!my_strcasecmp(system_charset_info,
cur_field->field_name, field_name))
l_field_name, field_name))
++cur_match_degree;
else
continue;
if (cur_field->table_name && table_name)
if (l_table_name && table_name)
{
/* If field_name is qualified by a table name. */
if (my_strcasecmp(table_alias_charset, cur_field->table_name, table_name))
if (my_strcasecmp(table_alias_charset, l_table_name, table_name))
/* Same field names, different tables. */
return NULL;
++cur_match_degree;
if (cur_field->db_name && db_name)
if (l_db_name && db_name)
{
/* If field_name is also qualified by a database name. */
if (strcmp(cur_field->db_name, db_name))
if (strcmp(l_db_name, db_name))
/* Same field names, different databases. */
return NULL;
++cur_match_degree;
}
}
}
else
continue;
if (cur_match_degree > found_match_degree)
{
found_match_degree= cur_match_degree;
found_group= cur_group;
}
else if (found_group && (cur_match_degree == found_match_degree) &&
! (*(found_group->item))->eq(cur_field, 0))
{
/*
If the current resolve candidate matches equally well as the current
best match, they must reference the same column, otherwise the field
is ambiguous.
*/
my_error(ER_NON_UNIQ_ERROR, MYF(0),
find_item->full_name(), current_thd->where);
return NULL;
}
if (cur_match_degree > found_match_degree)
{
found_match_degree= cur_match_degree;
found_group= cur_group;
}
else if (found_group && (cur_match_degree == found_match_degree) &&
!(*(found_group->item))->eq((*(cur_group->item)), 0))
{
/*
If the current resolve candidate matches equally well as the current
best match, they must reference the same column, otherwise the field
is ambiguous.
*/
my_error(ER_NON_UNIQ_ERROR, MYF(0),
find_item->full_name(), current_thd->where);
return NULL;
}
}
@ -5743,6 +5796,7 @@ String *Item::check_well_formed_result(String *str, bool send_error)
uint wlen= cs->cset->well_formed_len(cs,
str->ptr(), str->ptr() + str->length(),
str->length(), &well_formed_error);
null_value= false;
if (wlen < str->length())
{
THD *thd= current_thd;

View file

@ -3294,7 +3294,7 @@ public:
if (result_type() == ROW_RESULT)
orig_item->bring_value();
}
virtual bool is_expensive() { return orig_item->is_expensive(); }
bool is_expensive() { return orig_item->is_expensive(); }
bool is_expensive_processor(uchar *arg)
{ return orig_item->is_expensive_processor(arg); }
bool check_vcol_func_processor(uchar *arg)

View file

@ -6790,7 +6790,8 @@ Item_func_sp::init_result_field(THD *thd)
bool Item_func_sp::is_expensive()
{
return !(m_sp->m_chistics->detistic);
return !m_sp->m_chistics->detistic ||
current_thd->locked_tables_mode < LTM_LOCK_TABLES;
}

View file

@ -39,6 +39,7 @@ protected:
0 means get this number from first argument
*/
uint allowed_arg_cols;
String *val_str_from_val_str_ascii(String *str, String *str2);
void count_only_length(Item **item, uint nitems);
void count_real_length(Item **item, uint nitems);

View file

@ -70,7 +70,7 @@ size_t username_char_length= 16;
Normally conversion does not happen, and val_str_ascii() is immediately
returned instead.
*/
String *Item_str_func::val_str_from_val_str_ascii(String *str, String *str2)
String *Item_func::val_str_from_val_str_ascii(String *str, String *str2)
{
DBUG_ASSERT(fixed == 1);

View file

@ -62,7 +62,6 @@ public:
enum Item_result result_type () const { return STRING_RESULT; }
void left_right_max_length();
bool fix_fields(THD *thd, Item **ref);
String *val_str_from_val_str_ascii(String *str, String *str2);
};

View file

@ -1,5 +1,5 @@
/* Copyright (c) 2002, 2015, Oracle and/or its affiliates.
Copyright (c) 2010, 2015, MariaDB
/* Copyright (c) 2002, 2016, Oracle and/or its affiliates.
Copyright (c) 2010, 2016, MariaDB
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
@ -209,6 +209,7 @@ bool
Item_subselect::select_transformer(JOIN *join)
{
DBUG_ENTER("Item_subselect::select_transformer");
DBUG_ASSERT(thd == join->thd);
DBUG_RETURN(false);
}
@ -579,7 +580,7 @@ bool Item_subselect::is_expensive()
examined_rows+= cur_join->get_examined_rows();
}
// here we are sure that subquery is optimized so thd is set
return (examined_rows > thd->variables.expensive_subquery_limit);
}
@ -643,6 +644,7 @@ bool Item_subselect::exec()
subselect_engine *org_engine= engine;
DBUG_ENTER("Item_subselect::exec");
DBUG_ASSERT(fixed);
/*
Do not execute subselect in case of a fatal error
@ -688,6 +690,7 @@ int Item_in_subselect::optimize(double *out_rows, double *cost)
{
int res;
DBUG_ENTER("Item_in_subselect::optimize");
DBUG_ASSERT(fixed);
SELECT_LEX *save_select= thd->lex->current_select;
JOIN *join= unit->first_select()->join;
@ -802,6 +805,7 @@ bool Item_in_subselect::expr_cache_is_needed(THD *thd)
bool Item_in_subselect::exec()
{
DBUG_ENTER("Item_in_subselect::exec");
DBUG_ASSERT(fixed);
/*
Initialize the cache of the left predicate operand. This has to be done as
late as now, because Cached_item directly contains a resolved field (not
@ -856,6 +860,7 @@ table_map Item_subselect::used_tables() const
bool Item_subselect::const_item() const
{
DBUG_ASSERT(thd);
return (thd->lex->context_analysis_only ?
FALSE :
forced_const || const_item_cache);
@ -1049,10 +1054,11 @@ Item_singlerow_subselect::select_transformer(JOIN *join)
DBUG_ENTER("Item_singlerow_subselect::select_transformer");
if (changed)
DBUG_RETURN(false);
DBUG_ASSERT(join->thd == thd);
SELECT_LEX *select_lex= join->select_lex;
Query_arena *arena= thd->stmt_arena;
if (!select_lex->master_unit()->is_union() &&
!select_lex->table_list.elements &&
select_lex->item_list.elements == 1 &&
@ -1717,6 +1723,7 @@ Item_in_subselect::single_value_transformer(JOIN *join)
{
SELECT_LEX *select_lex= join->select_lex;
DBUG_ENTER("Item_in_subselect::single_value_transformer");
DBUG_ASSERT(thd == join->thd);
/*
Check that the right part of the subselect contains no more than one
@ -1829,9 +1836,9 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join)
if (!test_strategy(SUBS_MAXMIN_INJECTED | SUBS_MAXMIN_ENGINE))
DBUG_RETURN(false);
Item **place= optimizer->arguments() + 1;
THD *thd= join->thd;
SELECT_LEX *select_lex= join->select_lex;
Item *subs;
DBUG_ASSERT(thd == join->thd);
/*
*/
@ -1938,6 +1945,7 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join)
bool Item_in_subselect::fix_having(Item *having, SELECT_LEX *select_lex)
{
bool fix_res= 0;
DBUG_ASSERT(thd);
if (!having->fixed)
{
select_lex->having_fix_field= 1;
@ -2000,6 +2008,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
Item **having_item)
{
SELECT_LEX *select_lex= join->select_lex;
DBUG_ASSERT(thd == join->thd);
/*
The non-transformed HAVING clause of 'join' may be stored in two ways
during JOIN::optimize: this->tmp_having= this->having; this->having= 0;
@ -2136,6 +2145,7 @@ Item_in_subselect::row_value_transformer(JOIN *join)
uint cols_num= left_expr->cols();
DBUG_ENTER("Item_in_subselect::row_value_transformer");
DBUG_ASSERT(thd == join->thd);
// psergey: duplicated_subselect_card_check
if (select_lex->item_list.elements != cols_num)
@ -2248,6 +2258,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
!select_lex->table_list.elements);
DBUG_ENTER("Item_in_subselect::create_row_in_to_exists_cond");
DBUG_ASSERT(thd == join->thd);
*where_item= NULL;
*having_item= NULL;
@ -2473,6 +2484,7 @@ bool Item_in_subselect::inject_in_to_exists_cond(JOIN *join_arg)
Item *having_item= join_arg->in_to_exists_having;
DBUG_ENTER("Item_in_subselect::inject_in_to_exists_cond");
DBUG_ASSERT(thd == join_arg->thd);
if (where_item)
{
@ -2561,6 +2573,7 @@ Item_in_subselect::select_in_like_transformer(JOIN *join)
bool result;
DBUG_ENTER("Item_in_subselect::select_in_like_transformer");
DBUG_ASSERT(thd == join->thd);
/*
IN/SOME/ALL/ANY subqueries aren't support LIMIT clause. Without it
@ -2762,6 +2775,7 @@ bool Item_in_subselect::setup_mat_engine()
subselect_single_select_engine *select_engine;
DBUG_ENTER("Item_in_subselect::setup_mat_engine");
DBUG_ASSERT(thd);
/*
The select_engine (that executes transformed IN=>EXISTS subselects) is
@ -2800,6 +2814,7 @@ bool Item_in_subselect::setup_mat_engine()
bool Item_in_subselect::init_left_expr_cache()
{
JOIN *outer_join;
DBUG_ASSERT(thd);
outer_join= unit->outer_select()->join;
/*
@ -2826,6 +2841,7 @@ bool Item_in_subselect::init_left_expr_cache()
bool Item_in_subselect::init_cond_guards()
{
DBUG_ASSERT(thd);
uint cols_num= left_expr->cols();
if (!abort_on_null && left_expr->maybe_null && !pushed_cond_guards)
{
@ -2953,8 +2969,12 @@ bool subselect_union_engine::is_executed() const
bool subselect_union_engine::no_rows()
{
bool rows_present= false;
/* Check if we got any rows when reading UNION result from temp. table: */
return test(!unit->fake_select_lex->join->send_records);
if (unit->fake_select_lex->join)
rows_present= test(!unit->fake_select_lex->join->send_records);
return rows_present;
}
@ -4336,9 +4356,9 @@ bool subselect_hash_sj_engine::init(List<Item> *tmp_columns, uint subquery_id)
result= result_sink;
/*
If the subquery has blobs, or the total key lenght is bigger than
If the subquery has blobs, or the total key length is bigger than
some length, or the total number of key parts is more than the
allowed maximum (currently MAX_REF_PARTS == 16), then the created
allowed maximum (currently MAX_REF_PARTS == 32), then the created
index cannot be used for lookups and we can't use hash semi
join. If this is the case, delete the temporary table since it
will not be used, and tell the caller we failed to initialize the
@ -6089,4 +6109,3 @@ end:
void subselect_table_scan_engine::cleanup()
{
}

View file

@ -1455,25 +1455,29 @@ bool get_interval_value(Item *args,interval_type int_type, INTERVAL *interval)
void Item_temporal_func::fix_length_and_dec()
{
uint char_length= mysql_temporal_int_part_length(field_type());
/*
We set maybe_null to 1 as default as any bad argument with date or
time can get us to return NULL.
*/
maybe_null= 1;
max_length= mysql_temporal_int_part_length(field_type());
if (decimals)
{
if (decimals == NOT_FIXED_DEC)
max_length+= TIME_SECOND_PART_DIGITS + 1;
char_length+= TIME_SECOND_PART_DIGITS + 1;
else
{
set_if_smaller(decimals, TIME_SECOND_PART_DIGITS);
max_length+= decimals + 1;
char_length+= decimals + 1;
}
}
sql_mode= current_thd->variables.sql_mode &
(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE);
collation.set(&my_charset_numeric, DERIVATION_NUMERIC, MY_REPERTOIRE_ASCII);
collation.set(field_type() == MYSQL_TYPE_STRING ?
default_charset() : &my_charset_numeric,
DERIVATION_NUMERIC, MY_REPERTOIRE_ASCII);
fix_char_length(char_length);
}
String *Item_temporal_func::val_str(String *str)
@ -1483,6 +1487,23 @@ String *Item_temporal_func::val_str(String *str)
}
String *Item_temporal_hybrid_func::val_str_ascii(String *str)
{
DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime;
if (get_date(&ltime, 0) ||
(null_value= my_TIME_to_str(&ltime, str, decimals)))
return (String *) 0;
/* Check that the returned timestamp type matches to the function type */
DBUG_ASSERT(cached_field_type == MYSQL_TYPE_STRING ||
ltime.time_type == MYSQL_TIMESTAMP_NONE ||
mysql_type_to_time_type(cached_field_type) == ltime.time_type);
return str;
}
bool Item_func_from_days::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
{
longlong value=args[0]->val_int();

View file

@ -506,6 +506,50 @@ public:
};
/**
Abstract class for functions returning TIME, DATE, DATETIME or string values,
whose data type depends on parameters and is set at fix_fields time.
*/
class Item_temporal_hybrid_func: public Item_temporal_func
{
protected:
enum_field_types cached_field_type; // TIME, DATE, DATETIME or STRING
String ascii_buf; // Conversion buffer
public:
Item_temporal_hybrid_func(Item *a,Item *b)
:Item_temporal_func(a,b) {}
enum_field_types field_type() const { return cached_field_type; }
Item_result cmp_type() const
{
return cached_field_type == MYSQL_TYPE_STRING ?
STRING_RESULT : TIME_RESULT;
}
const CHARSET_INFO *charset_for_protocol() const
{
/*
Can return TIME, DATE, DATETIME or VARCHAR depending on arguments.
Send using "binary" when TIME, DATE or DATETIME,
or using collation.collation when VARCHAR
(which is fixed from @@collation_connection in fix_length_and_dec).
*/
DBUG_ASSERT(fixed == 1);
return cached_field_type == MYSQL_TYPE_STRING ?
collation.collation : &my_charset_bin;
}
/**
Return string value in ASCII character set.
*/
String *val_str_ascii(String *str);
/**
Return string value in @@character_set_connection.
*/
String *val_str(String *str)
{
return val_str_from_val_str_ascii(str, &ascii_buf);
}
};
class Item_datefunc :public Item_temporal_func
{
public:
@ -763,17 +807,15 @@ public:
};
class Item_date_add_interval :public Item_temporal_func
class Item_date_add_interval :public Item_temporal_hybrid_func
{
enum_field_types cached_field_type;
public:
const interval_type int_type; // keep it public
const bool date_sub_interval; // keep it public
Item_date_add_interval(Item *a,Item *b,interval_type type_arg,bool neg_arg)
:Item_temporal_func(a,b),int_type(type_arg), date_sub_interval(neg_arg) {}
:Item_temporal_hybrid_func(a,b),int_type(type_arg), date_sub_interval(neg_arg) {}
const char *func_name() const { return "date_add_interval"; }
void fix_length_and_dec();
enum_field_types field_type() const { return cached_field_type; }
bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date);
bool eq(const Item *item, bool binary_cmp) const;
void print(String *str, enum_query_type query_type);
@ -911,16 +953,14 @@ public:
};
class Item_func_add_time :public Item_temporal_func
class Item_func_add_time :public Item_temporal_hybrid_func
{
const bool is_date;
int sign;
enum_field_types cached_field_type;
public:
Item_func_add_time(Item *a, Item *b, bool type_arg, bool neg_arg)
:Item_temporal_func(a, b), is_date(type_arg) { sign= neg_arg ? -1 : 1; }
enum_field_types field_type() const { return cached_field_type; }
:Item_temporal_hybrid_func(a, b), is_date(type_arg) { sign= neg_arg ? -1 : 1; }
void fix_length_and_dec();
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date);
void print(String *str, enum_query_type query_type);
@ -1019,9 +1059,8 @@ public:
};
class Item_func_str_to_date :public Item_temporal_func
class Item_func_str_to_date :public Item_temporal_hybrid_func
{
enum_field_types cached_field_type;
timestamp_type cached_timestamp_type;
bool const_item;
String subject_converter;
@ -1029,12 +1068,11 @@ class Item_func_str_to_date :public Item_temporal_func
CHARSET_INFO *internal_charset;
public:
Item_func_str_to_date(Item *a, Item *b)
:Item_temporal_func(a, b), const_item(false),
:Item_temporal_hybrid_func(a, b), const_item(false),
internal_charset(NULL)
{}
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date);
const char *func_name() const { return "str_to_date"; }
enum_field_types field_type() const { return cached_field_type; }
void fix_length_and_dec();
};

View file

@ -266,6 +266,9 @@ public:
{
compute_statistics();
truncate(0);
if(cache_log.file != -1)
my_chsize(cache_log.file, 0, 0, MYF(MY_WME));
changes_to_non_trans_temp_table_flag= FALSE;
incident= FALSE;
before_stmt_pos= MY_OFF_T_UNDEF;
@ -3161,7 +3164,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name,
if (init_and_set_log_file_name(log_name, new_name, log_type_arg,
io_cache_type_arg))
{
sql_print_error("MSYQL_BIN_LOG::open failed to generate new file name.");
sql_print_error("MYSQL_BIN_LOG::open failed to generate new file name.");
DBUG_RETURN(1);
}
@ -3188,7 +3191,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name,
}
});
sql_print_error("MSYQL_BIN_LOG::open failed to sync the index file.");
sql_print_error("MYSQL_BIN_LOG::open failed to sync the index file.");
DBUG_RETURN(1);
}
DBUG_EXECUTE_IF("crash_create_non_critical_before_update_index", DBUG_SUICIDE(););
@ -3951,14 +3954,14 @@ int MYSQL_BIN_LOG::purge_logs(const char *to_log,
if ((error= sync_purge_index_file()))
{
sql_print_error("MSYQL_BIN_LOG::purge_logs failed to flush register file.");
sql_print_error("MYSQL_BIN_LOG::purge_logs failed to flush register file.");
goto err;
}
/* We know how many files to delete. Update index file. */
if ((error=update_log_index(&log_info, need_update_threads)))
{
sql_print_error("MSYQL_BIN_LOG::purge_logs failed to update the index file");
sql_print_error("MYSQL_BIN_LOG::purge_logs failed to update the index file");
goto err;
}
@ -3968,7 +3971,7 @@ err:
/* Read each entry from purge_index_file and delete the file. */
if (is_inited_purge_index_file() &&
(error= purge_index_entry(thd, reclaimed_space, FALSE)))
sql_print_error("MSYQL_BIN_LOG::purge_logs failed to process registered files"
sql_print_error("MYSQL_BIN_LOG::purge_logs failed to process registered files"
" that would be purged.");
close_purge_index_file();
@ -4085,7 +4088,7 @@ int MYSQL_BIN_LOG::purge_index_entry(THD *thd, ulonglong *reclaimed_space,
if ((error=reinit_io_cache(&purge_index_file, READ_CACHE, 0, 0, 0)))
{
sql_print_error("MSYQL_BIN_LOG::purge_index_entry failed to reinit register file "
sql_print_error("MYSQL_BIN_LOG::purge_index_entry failed to reinit register file "
"for read");
goto err;
}
@ -4100,7 +4103,7 @@ int MYSQL_BIN_LOG::purge_index_entry(THD *thd, ulonglong *reclaimed_space,
if (purge_index_file.error)
{
error= purge_index_file.error;
sql_print_error("MSYQL_BIN_LOG::purge_index_entry error %d reading from "
sql_print_error("MYSQL_BIN_LOG::purge_index_entry error %d reading from "
"register file.", error);
goto err;
}

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