Commit baacac34 authored by Timothy Smith's avatar Timothy Smith

Auto merge from upstream 5.1-bugteam

parents 5681a0df 0772b6a8
......@@ -2020,7 +2020,7 @@ static bool add_line(String &buffer,char *line,char *in_string,
{
if (!preserve_comments)
{
// Skip spaces at the beggining of a statement
// Skip spaces at the beginning of a statement
if (my_isspace(charset_info,inchar) && (out == line) &&
buffer.is_empty())
continue;
......@@ -2103,37 +2103,6 @@ static bool add_line(String &buffer,char *line,char *in_string,
continue;
}
}
else if (!*ml_comment && !*in_string &&
(end_of_line - pos) >= 10 &&
!my_strnncoll(charset_info, (uchar*) pos, 10,
(const uchar*) "delimiter ", 10))
{
// Flush previously accepted characters
if (out != line)
{
buffer.append(line, (uint32) (out - line));
out= line;
}
// Flush possible comments in the buffer
if (!buffer.is_empty())
{
if (com_go(&buffer, 0) > 0) // < 0 is not fatal
DBUG_RETURN(1);
buffer.length(0);
}
/*
Delimiter wants the get rest of the given line as argument to
allow one to change ';' to ';;' and back
*/
buffer.append(pos);
if (com_delimiter(&buffer, pos) > 0)
DBUG_RETURN(1);
buffer.length(0);
break;
}
else if (!*ml_comment && !*in_string && is_prefix(pos, delimiter))
{
// Found a statement. Continue parsing after the delimiter
......@@ -2196,8 +2165,24 @@ static bool add_line(String &buffer,char *line,char *in_string,
// comment to end of line
if (preserve_comments)
{
bool started_with_nothing= !buffer.length();
buffer.append(pos);
/*
A single-line comment by itself gets sent immediately so that
client commands (delimiter, status, etc) will be interpreted on
the next line.
*/
if (started_with_nothing)
{
if (com_go(&buffer, 0) > 0) // < 0 is not fatal
DBUG_RETURN(1);
buffer.length(0);
}
}
break;
}
else if (!*in_string && inchar == '/' && *(pos+1) == '*' &&
......
......@@ -671,8 +671,11 @@ call p_verify_status_increment(2, 2, 2, 2);
savepoint a;
call p_verify_status_increment(0, 0, 0, 0);
insert t1 set a=4;
--echo # Sic: a bug. Binlog did not register itself this time.
call p_verify_status_increment(1, 0, 1, 0);
--echo # Binlog does not register itself this time for other than the 1st
--echo # statement of the transaction with MIXED/STATEMENT binlog_format.
--echo # It needs registering with the ROW format. Therefore 1,0,2,2 are
--echo # the correct arguments to this test after bug#40221 fixed.
call p_verify_status_increment(1, 0, 2, 2);
release savepoint a;
rollback;
call p_verify_status_increment(0, 0, 0, 0);
......
......@@ -2386,6 +2386,9 @@ sub remove_stale_vardir () {
mtr_verbose("Removing $opt_vardir/");
mtr_rmtree("$opt_vardir/");
}
# Remove the "tmp" dir
mtr_verbose("Removing $opt_tmpdir/");
mtr_rmtree("$opt_tmpdir/");
}
#
......
......@@ -770,8 +770,11 @@ call p_verify_status_increment(0, 0, 0, 0);
SUCCESS
insert t1 set a=4;
# Sic: a bug. Binlog did not register itself this time.
call p_verify_status_increment(1, 0, 1, 0);
# Binlog does not register itself this time for other than the 1st
# statement of the transaction with MIXED/STATEMENT binlog_format.
# It needs registering with the ROW format. Therefore 1,0,2,2 are
# the correct arguments to this test after bug#40221 fixed.
call p_verify_status_increment(1, 0, 2, 2);
SUCCESS
release savepoint a;
......
......@@ -176,4 +176,13 @@ IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((R
DROP TABLE t1;
CREATE TABLE t1 (c LONGTEXT);
INSERT INTO t1 VALUES(1), (2), (3), (4), ('12345678901234567890');
SELECT * FROM (SELECT MAX(IF(1, CAST(c AS UNSIGNED), 0)) FROM t1) AS te;
MAX(IF(1, CAST(c AS UNSIGNED), 0))
12345678901234567890
SELECT * FROM (SELECT MAX(IFNULL(CAST(c AS UNSIGNED), 0)) FROM t1) AS te;
MAX(IFNULL(CAST(c AS UNSIGNED), 0))
12345678901234567890
DROP TABLE t1;
End of 5.0 tests
......@@ -10,10 +10,7 @@ create table t2 (a INT);
SELECT @@log_bin_trust_function_creators;
@@log_bin_trust_function_creators
0
SELECT @@sql_log_bin;
@@sql_log_bin
1
## Creating new function f1 ##
## Creating new function f1 fails because no DETERMINISTIC ###
CREATE FUNCTION f1(a INT) RETURNS INT
BEGIN
IF (a < 3) THEN
......@@ -21,8 +18,24 @@ INSERT INTO t2 VALUES (a);
END IF;
RETURN 1;
END|
'Bug: Create Function should give error here because non-super user';
'is creating function here';
ERROR HY000: This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
## Creating new function f1 fails because non-super user ##
CREATE FUNCTION f1(a INT) RETURNS INT DETERMINISTIC
BEGIN
IF (a < 3) THEN
INSERT INTO t2 VALUES (a);
END IF;
RETURN 1;
END|
ERROR HY000: You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
## Creating new function f1 succeeds ##
CREATE FUNCTION f1(a INT) RETURNS INT DETERMINISTIC
BEGIN
IF (a < 3) THEN
INSERT INTO t2 VALUES (a);
END IF;
RETURN 1;
END|
## Creating new table t1 ##
CREATE TABLE t1 (a INT);
## Inserting some records in t1 ##
......
......@@ -180,6 +180,12 @@ ERROR at line 1: DELIMITER cannot contain a backslash character
1
This is a file starting with UTF8 BOM 0xEFBBBF
This is a file starting with UTF8 BOM 0xEFBBBF
delimiter
1
2
2
2
2
End of 5.0 tests
WARNING: --server-arg option not supported in this configuration.
Warning (Code 1286): Unknown table engine 'nonexistent'
......
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
stop slave;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (id INT);
start slave;
SET GLOBAL debug= "+d,crash_before_purge_logs";
FLUSH LOGS;
ERROR HY000: Lost connection to MySQL server during query
start slave;
--source include/master-slave.inc
--source include/have_debug.inc
--disable_reconnect
# We have to sync with master, to ensure slave had time to start properly
# # before we stop it. If not, we get errors about UNIX_TIMESTAMP() in the
# log.
sync_slave_with_master;
stop slave;
--source include/wait_for_slave_to_stop.inc
# ON MASTER
connection master;
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (id INT);
let $1=100;
disable_query_log;
begin;
while ($1)
{
eval INSERT INTO t1 VALUES( $1 );
dec $1;
}
DROP TABLE t1;
save_master_pos;
enable_query_log;
## ON SLAVE
connection slave;
start slave;
--source include/wait_for_slave_to_start.inc
sync_with_master 0;
connection master;
save_master_pos;
connection slave;
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/slave0.expect
SET GLOBAL debug= "+d,crash_before_purge_logs";
--error 2013
# try to rotate logs
FLUSH LOGS;
--enable_reconnect
--source include/wait_until_connected_again.inc
start slave;
--source include/wait_for_slave_to_start.inc
sync_with_master 0;
......@@ -150,4 +150,18 @@ FROM t1;
DROP TABLE t1;
#
# Bug #40761: Assert on sum func on IF(..., CAST(longtext AS UNSIGNED), signed)
# (was: LEFT JOIN on inline view crashes server)
#
CREATE TABLE t1 (c LONGTEXT);
INSERT INTO t1 VALUES(1), (2), (3), (4), ('12345678901234567890');
SELECT * FROM (SELECT MAX(IF(1, CAST(c AS UNSIGNED), 0)) FROM t1) AS te;
SELECT * FROM (SELECT MAX(IFNULL(CAST(c AS UNSIGNED), 0)) FROM t1) AS te;
DROP TABLE t1;
--echo End of 5.0 tests
......@@ -20,6 +20,8 @@
# #
###############################################################################
source include/have_log_bin.inc;
--disable_warnings
drop table if exists t1;
--enable_warnings
......@@ -45,10 +47,10 @@ connect (test_con1,localhost,tt,,);
connection test_con1;
SELECT @@log_bin_trust_function_creators;
SELECT @@sql_log_bin;
--echo ## Creating new function f1 ##
--echo ## Creating new function f1 fails because no DETERMINISTIC ###
delimiter |;
--error ER_BINLOG_UNSAFE_ROUTINE
CREATE FUNCTION f1(a INT) RETURNS INT
BEGIN
IF (a < 3) THEN
......@@ -58,8 +60,30 @@ BEGIN
END|
delimiter ;|
--echo 'Bug: Create Function should give error here because non-super user';
--echo 'is creating function here';
--echo ## Creating new function f1 fails because non-super user ##
delimiter |;
--error ER_BINLOG_CREATE_ROUTINE_NEED_SUPER
CREATE FUNCTION f1(a INT) RETURNS INT DETERMINISTIC
BEGIN
IF (a < 3) THEN
INSERT INTO t2 VALUES (a);
END IF;
RETURN 1;
END|
delimiter ;|
connection default;
--echo ## Creating new function f1 succeeds ##
delimiter |;
CREATE FUNCTION f1(a INT) RETURNS INT DETERMINISTIC
BEGIN
IF (a < 3) THEN
INSERT INTO t2 VALUES (a);
END IF;
RETURN 1;
END|
delimiter ;|
--echo ## Creating new table t1 ##
CREATE TABLE t1 (a INT);
......
......@@ -291,6 +291,25 @@ EOF
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug29323.sql 2>&1
remove_file $MYSQLTEST_VARDIR/tmp/bug29323.sql;
#
# Bug #33812: mysql client incorrectly parsing DELIMITER
#
# The space and ; after delimiter are important
--exec $MYSQL -e "select 1 delimiter ;"
#
# Bug #38158: mysql client regression, can't read dump files
#
--write_file $MYSQLTEST_VARDIR/tmp/bug38158.sql
-- Testing
--
delimiter ||
select 2 ||
EOF
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug38158.sql 2>&1
--exec $MYSQL -c < $MYSQLTEST_VARDIR/tmp/bug38158.sql 2>&1
remove_file $MYSQLTEST_VARDIR/tmp/bug38158.sql;
--echo End of 5.0 tests
#
......
......@@ -362,7 +362,10 @@ public:
Item_func_unsigned(Item *a) :Item_func_signed(a) {}
const char *func_name() const { return "cast_as_unsigned"; }
void fix_length_and_dec()
{ max_length=args[0]->max_length; unsigned_flag=1; }
{
max_length= min(args[0]->max_length, DECIMAL_MAX_PRECISION + 2);
unsigned_flag=1;
}
longlong val_int();
virtual void print(String *str, enum_query_type query_type);
};
......
......@@ -2978,7 +2978,7 @@ int MYSQL_BIN_LOG::purge_first_log(Relay_log_info* rli, bool included)
* Need to update the log pos because purge logs has been called
* after fetching initially the log pos at the begining of the method.
*/
if(error=find_log_pos(&rli->linfo, rli->event_relay_log_name, 0))
if((error=find_log_pos(&rli->linfo, rli->event_relay_log_name, 0)))
{
char buff[22];
sql_print_error("next log error: %d offset: %s log: %s included: %d",
......@@ -3044,7 +3044,6 @@ int MYSQL_BIN_LOG::purge_logs(const char *to_log,
ulonglong *decrease_log_space)
{
int error;
int ret = 0;
bool exit_loop= 0;
LOG_INFO log_info;
THD *thd= current_thd;
......@@ -3067,8 +3066,8 @@ int MYSQL_BIN_LOG::purge_logs(const char *to_log,
*/
if (!my_b_inited(&purge_temp))
{
if (error=open_cached_file(&purge_temp, mysql_tmpdir, TEMP_PREFIX,
DISK_BUFFER_SIZE, MYF(MY_WME)))
if ((error=open_cached_file(&purge_temp, mysql_tmpdir, TEMP_PREFIX,
DISK_BUFFER_SIZE, MYF(MY_WME))))
{
sql_print_error("MYSQL_LOG::purge_logs failed to open purge_temp");
goto err;
......@@ -3076,7 +3075,7 @@ int MYSQL_BIN_LOG::purge_logs(const char *to_log,
}
else
{
if (error=reinit_io_cache(&purge_temp, WRITE_CACHE, 0, 0, 1))
if ((error=reinit_io_cache(&purge_temp, WRITE_CACHE, 0, 0, 1)))
{
sql_print_error("MYSQL_LOG::purge_logs failed to reinit purge_temp "
"for write");
......@@ -3107,7 +3106,7 @@ int MYSQL_BIN_LOG::purge_logs(const char *to_log,
}
/* We know how many files to delete. Update index file. */
if (error=update_log_index(&log_info, need_update_threads))
if ((error=update_log_index(&log_info, need_update_threads)))
{
sql_print_error("MSYQL_LOG::purge_logs failed to update the index file");
goto err;
......@@ -3116,7 +3115,7 @@ int MYSQL_BIN_LOG::purge_logs(const char *to_log,
DBUG_EXECUTE_IF("crash_after_update_index", abort(););
/* Switch purge_temp for read. */
if (error=reinit_io_cache(&purge_temp, READ_CACHE, 0, 0, 0))
if ((error=reinit_io_cache(&purge_temp, READ_CACHE, 0, 0, 0)))
{
sql_print_error("MSYQL_LOG::purge_logs failed to reinit purge_temp "
"for read");
......@@ -3251,6 +3250,7 @@ int MYSQL_BIN_LOG::purge_logs(const char *to_log,
}
err:
close_cached_file(&purge_temp);
if (need_mutex)
pthread_mutex_unlock(&LOCK_index);
DBUG_RETURN(error);
......
......@@ -16552,6 +16552,7 @@ static void test_change_user()
DBUG_VOID_RETURN;
}
#ifdef HAVE_SPATIAL
/**
Bug#37956 memory leak and / or crash with geometry and prepared statements!
*/
......@@ -16560,7 +16561,7 @@ static void test_bug37956(void)
{
const char *query="select point(?,?)";
MYSQL_STMT *stmt=NULL;
unsigned int val=0;
ulong val=0;
MYSQL_BIND bind_param[2];
unsigned char buff[2]= { 134, 211 };
DBUG_ENTER("test_bug37956");
......@@ -16604,6 +16605,7 @@ static void test_bug37956(void)
DIE_UNLESS(0);
DBUG_VOID_RETURN;
}
#endif
/*
Bug#27592 (stack overrun when storing datetime value using prepared statements)
......@@ -18020,7 +18022,9 @@ static struct my_tests_st my_tests[]= {
{ "test_wl4166_2", test_wl4166_2 },
{ "test_bug38486", test_bug38486 },
{ "test_bug40365", test_bug40365 },
#ifdef HAVE_SPATIAL
{ "test_bug37956", test_bug37956 },
#endif
{ 0, 0 }
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment