Commit cbcf22d1 authored by msvensson@neptunus.(none)'s avatar msvensson@neptunus.(none)

Merge bk-internal:/home/bk/mysql-5.0-maint

into  neptunus.(none):/home/msvensson/mysql/mysql-5.0-maint
parents 225b3e48 5ed44ed0
...@@ -7,3 +7,5 @@ ...@@ -7,3 +7,5 @@
4513d8e4Af4dQWuk13sArwofRgFDQw 4513d8e4Af4dQWuk13sArwofRgFDQw
4519a6c5BVUxEHTf5iJnjZkixMBs8g 4519a6c5BVUxEHTf5iJnjZkixMBs8g
451ab499rgdjXyOnUDqHu-wBDoS-OQ 451ab499rgdjXyOnUDqHu-wBDoS-OQ
45214442pBGT9KuZEGixBH71jTzbOA
45214a07hVsIGwvwa-WrO-jpeaSwVw
...@@ -3104,7 +3104,7 @@ static int do_reset_master(MYSQL *mysql_con) ...@@ -3104,7 +3104,7 @@ static int do_reset_master(MYSQL *mysql_con)
} }
static int start_transaction(MYSQL *mysql_con, my_bool consistent_read_now) static int start_transaction(MYSQL *mysql_con)
{ {
/* /*
We use BEGIN for old servers. --single-transaction --master-data will fail We use BEGIN for old servers. --single-transaction --master-data will fail
...@@ -3119,10 +3119,8 @@ static int start_transaction(MYSQL *mysql_con, my_bool consistent_read_now) ...@@ -3119,10 +3119,8 @@ static int start_transaction(MYSQL *mysql_con, my_bool consistent_read_now)
"SET SESSION TRANSACTION ISOLATION " "SET SESSION TRANSACTION ISOLATION "
"LEVEL REPEATABLE READ") || "LEVEL REPEATABLE READ") ||
mysql_query_with_error_report(mysql_con, 0, mysql_query_with_error_report(mysql_con, 0,
consistent_read_now ?
"START TRANSACTION " "START TRANSACTION "
"WITH CONSISTENT SNAPSHOT" : "/*!40100 WITH CONSISTENT SNAPSHOT */"));
"BEGIN"));
} }
...@@ -3612,7 +3610,7 @@ int main(int argc, char **argv) ...@@ -3612,7 +3610,7 @@ int main(int argc, char **argv)
if ((opt_lock_all_tables || opt_master_data) && if ((opt_lock_all_tables || opt_master_data) &&
do_flush_tables_read_lock(mysql)) do_flush_tables_read_lock(mysql))
goto err; goto err;
if (opt_single_transaction && start_transaction(mysql, test(opt_master_data))) if (opt_single_transaction && start_transaction(mysql))
goto err; goto err;
if (opt_delete_master_logs && do_reset_master(mysql)) if (opt_delete_master_logs && do_reset_master(mysql))
goto err; goto err;
......
...@@ -130,3 +130,36 @@ prepare st_18492 from 'select * from t1 where 3 in (select (1+1) union select 1) ...@@ -130,3 +130,36 @@ prepare st_18492 from 'select * from t1 where 3 in (select (1+1) union select 1)
execute st_18492; execute st_18492;
a a
drop table t1; drop table t1;
create table t1 (a int, b varchar(4));
create table t2 (a int, b varchar(4), primary key(a));
prepare stmt1 from 'insert into t1 (a, b) values (?, ?)';
prepare stmt2 from 'insert into t2 (a, b) values (?, ?)';
set @intarg= 11;
set @varchararg= '2222';
execute stmt1 using @intarg, @varchararg;
execute stmt2 using @intarg, @varchararg;
set @intarg= 12;
execute stmt1 using @intarg, @UNDEFINED;
execute stmt2 using @intarg, @UNDEFINED;
set @intarg= 13;
execute stmt1 using @UNDEFINED, @varchararg;
execute stmt2 using @UNDEFINED, @varchararg;
ERROR 23000: Column 'a' cannot be null
set @intarg= 14;
set @nullarg= Null;
execute stmt1 using @UNDEFINED, @nullarg;
execute stmt2 using @nullarg, @varchararg;
ERROR 23000: Column 'a' cannot be null
select * from t1;
a b
11 2222
12 NULL
NULL 2222
NULL NULL
select * from t2;
a b
11 2222
12 NULL
drop table t1;
drop table t2;
End of 5.0 tests.
...@@ -215,6 +215,7 @@ select @@version; ...@@ -215,6 +215,7 @@ select @@version;
select @@global.version; select @@global.version;
@@global.version @@global.version
# #
End of 4.1 tests
set @first_var= NULL; set @first_var= NULL;
create table t1 select @first_var; create table t1 select @first_var;
show create table t1; show create table t1;
...@@ -301,3 +302,11 @@ select @var; ...@@ -301,3 +302,11 @@ select @var;
@var @var
3 3
drop table t1; drop table t1;
insert into city 'blah';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''blah'' at line 1
SHOW COUNT(*) WARNINGS;
@@session.warning_count
1
SHOW COUNT(*) ERRORS;
@@session.error_count
1
...@@ -144,3 +144,37 @@ prepare st_18492 from 'select * from t1 where 3 in (select (1+1) union select 1) ...@@ -144,3 +144,37 @@ prepare st_18492 from 'select * from t1 where 3 in (select (1+1) union select 1)
execute st_18492; execute st_18492;
drop table t1; drop table t1;
#
# Bug#19356: Assertion failure with undefined @uservar in prepared statement execution
#
create table t1 (a int, b varchar(4));
create table t2 (a int, b varchar(4), primary key(a));
prepare stmt1 from 'insert into t1 (a, b) values (?, ?)';
prepare stmt2 from 'insert into t2 (a, b) values (?, ?)';
set @intarg= 11;
set @varchararg= '2222';
execute stmt1 using @intarg, @varchararg;
execute stmt2 using @intarg, @varchararg;
set @intarg= 12;
execute stmt1 using @intarg, @UNDEFINED;
execute stmt2 using @intarg, @UNDEFINED;
set @intarg= 13;
execute stmt1 using @UNDEFINED, @varchararg;
--error 1048
execute stmt2 using @UNDEFINED, @varchararg;
set @intarg= 14;
set @nullarg= Null;
execute stmt1 using @UNDEFINED, @nullarg;
--error 1048
execute stmt2 using @nullarg, @varchararg;
select * from t1;
select * from t2;
drop table t1;
drop table t2;
--echo End of 5.0 tests.
...@@ -144,6 +144,8 @@ select @@version; ...@@ -144,6 +144,8 @@ select @@version;
--replace_column 1 # --replace_column 1 #
select @@global.version; select @@global.version;
--echo End of 4.1 tests
# Bug #6598: problem with cast(NULL as signed integer); # Bug #6598: problem with cast(NULL as signed integer);
# #
...@@ -210,4 +212,10 @@ select @var:=f2 from t1 group by f1 order by f2 desc limit 1; ...@@ -210,4 +212,10 @@ select @var:=f2 from t1 group by f1 order by f2 desc limit 1;
select @var; select @var;
drop table t1; drop table t1;
# End of 4.1 tests #
# Bug#19024 - SHOW COUNT(*) WARNINGS not return Errors
#
--error 1064
insert into city 'blah';
SHOW COUNT(*) WARNINGS;
SHOW COUNT(*) ERRORS;
...@@ -2927,6 +2927,7 @@ static byte *get_warning_count(THD *thd) ...@@ -2927,6 +2927,7 @@ static byte *get_warning_count(THD *thd)
{ {
thd->sys_var_tmp.long_value= thd->sys_var_tmp.long_value=
(thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_NOTE] + (thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_NOTE] +
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR] +
thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_WARN]); thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_WARN]);
return (byte*) &thd->sys_var_tmp.long_value; return (byte*) &thd->sys_var_tmp.long_value;
} }
......
...@@ -2248,6 +2248,14 @@ void mysql_stmt_execute(THD *thd, char *packet_arg, uint packet_length) ...@@ -2248,6 +2248,14 @@ void mysql_stmt_execute(THD *thd, char *packet_arg, uint packet_length)
#endif #endif
if (!(specialflag & SPECIAL_NO_PRIOR)) if (!(specialflag & SPECIAL_NO_PRIOR))
my_pthread_setprio(pthread_self(),QUERY_PRIOR); my_pthread_setprio(pthread_self(),QUERY_PRIOR);
/*
If the free_list is not empty, we'll wrongly free some externally
allocated items when cleaning up after validation of the prepared
statement.
*/
DBUG_ASSERT(thd->free_list == NULL);
error= stmt->execute(&expanded_query, error= stmt->execute(&expanded_query,
test(flags & (ulong) CURSOR_TYPE_READ_ONLY)); test(flags & (ulong) CURSOR_TYPE_READ_ONLY));
if (!(specialflag & SPECIAL_NO_PRIOR)) if (!(specialflag & SPECIAL_NO_PRIOR))
...@@ -2310,6 +2318,13 @@ void mysql_sql_stmt_execute(THD *thd) ...@@ -2310,6 +2318,13 @@ void mysql_sql_stmt_execute(THD *thd)
DBUG_PRINT("info",("stmt: %p", stmt)); DBUG_PRINT("info",("stmt: %p", stmt));
/*
If the free_list is not empty, we'll wrongly free some externally
allocated items when cleaning up after validation of the prepared
statement.
*/
DBUG_ASSERT(thd->free_list == NULL);
if (stmt->set_params_from_vars(stmt, lex->prepared_stmt_params, if (stmt->set_params_from_vars(stmt, lex->prepared_stmt_params,
&expanded_query)) &expanded_query))
goto set_params_data_err; goto set_params_data_err;
...@@ -2788,12 +2803,12 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len) ...@@ -2788,12 +2803,12 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
external changes when cleaning up after validation. external changes when cleaning up after validation.
*/ */
DBUG_ASSERT(thd->change_list.is_empty()); DBUG_ASSERT(thd->change_list.is_empty());
/*
If the free_list is not empty, we'll wrongly free some externally /*
allocated items when cleaning up after validation of the prepared The only case where we should have items in the thd->free_list is
statement. after stmt->set_params_from_vars(), which may in some cases create
Item_null objects.
*/ */
DBUG_ASSERT(thd->free_list == NULL);
if (error == 0) if (error == 0)
error= check_prepared_statement(this, name.str != 0); error= check_prepared_statement(this, name.str != 0);
...@@ -2891,7 +2906,13 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) ...@@ -2891,7 +2906,13 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
allocated items when cleaning up after execution of this statement. allocated items when cleaning up after execution of this statement.
*/ */
DBUG_ASSERT(thd->change_list.is_empty()); DBUG_ASSERT(thd->change_list.is_empty());
DBUG_ASSERT(thd->free_list == NULL);
/*
The only case where we should have items in the thd->free_list is
after stmt->set_params_from_vars(), which may in some cases create
Item_null objects.
*/
thd->set_n_backup_statement(this, &stmt_backup); thd->set_n_backup_statement(this, &stmt_backup);
if (expanded_query->length() && if (expanded_query->length() &&
alloc_query(thd, (char*) expanded_query->ptr(), alloc_query(thd, (char*) expanded_query->ptr(),
......
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