1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Merge bk-internal.mysql.com:/home/bk/mysql-5.1

into  bodhi.(none):/opt/local/work/mysql-5.1-27430
This commit is contained in:
kostja@bodhi.(none)
2008-05-20 11:38:17 +04:00
47 changed files with 5573 additions and 5011 deletions

View File

@ -10,7 +10,6 @@
#
##############################################################################
federated_transactions : Bug#29523 Transactions do not work
ps_ddl : Bug#12093 2007-12-14 pending WL#4165 / WL#4166
csv_alter_table : Bug#33696 2008-01-21 pcrews no .result file - bug allows NULL columns in CSV tables
user_limits : Bug#23921 random failure of user_limits.test
status : Bug#32966 main.status fails

View File

@ -1266,6 +1266,12 @@ DROP DATABASE db27878;
use test;
DROP TABLE t1;
--echo #
--echo # Bug#33275 Server crash when creating temporary table mysql.user
--echo #
CREATE TEMPORARY TABLE mysql.user (id INT);
FLUSH PRIVILEGES;
DROP TABLE mysql.user;
#
# Bug #33201 Crash occurs when granting update privilege on one column of a view
#

View File

@ -231,6 +231,34 @@ set global slow_query_log_file= NULL;
set global general_log_file= @old_general_log_file;
set global slow_query_log_file= @old_slow_query_log_file;
###########################################################################
--echo
--echo # --
--echo # -- Bug#32748: Inconsistent handling of assignments to
--echo # -- general_log_file/slow_query_log_file.
--echo # --
--echo
SET @general_log_file_saved = @@global.general_log_file;
SET @slow_query_log_file_saved = @@global.slow_query_log_file;
--echo
SET GLOBAL general_log_file = 'bug32748.query.log';
SET GLOBAL slow_query_log_file = 'bug32748.slow.log';
--echo
SHOW VARIABLES LIKE '%log_file';
--echo
SET GLOBAL general_log_file = @general_log_file_saved;
SET GLOBAL slow_query_log_file = @slow_query_log_file_saved;
--echo
--echo # -- End of Bug#32748.
###########################################################################
--echo End of 5.1 tests
--enable_ps_protocol

View File

@ -181,7 +181,7 @@ create table t5
a int primary key,
b char(30),
c int,
d timestamp default current_timestamp
d timestamp default '2008-02-23 09:23:45'
);
insert into t5( a, b, c) values( 9, 'recreated table', 9);
execute stmt2 ;
@ -191,7 +191,7 @@ drop table t5 ;
create table t5
(
a int primary key,
d timestamp default current_timestamp,
d timestamp default '2008-02-23 09:23:45',
b char(30),
c int
);
@ -218,7 +218,6 @@ create table t5
f3 int
);
insert into t5( f1, f2, f3) values( 9, 'recreated table', 9);
--error 1054
execute stmt2 ;
drop table t5 ;

File diff suppressed because it is too large Load Diff

398
mysql-test/t/ps_ddl1.test Normal file
View File

@ -0,0 +1,398 @@
#
# Testing the behavior of 'PREPARE', 'DDL', 'EXECUTE' scenarios
#
# There are several subtests which are probably "superfluous" because a DDL
# statement before the EXECUTE <prepared stmt handle> contained a keyword
# or action (Example: Alter) which causes that all prepared statements using
# the modified object are reprepared before execution.
# Please do not delete these subtests if they disturb. Just disable them by
# if (0)
# {
# <tests to disable>
# }.
# There might be future optimisations of the server which decrease the amount
# of unneeded reprepares or skip unneeded prepare steps and than these subtests
# might become valuable.
# Example:
# Every preceding ALTER TABLE seems to cause a reprepare.
# But if the ALTER only changed the table comment ...
#
# Created: 2008-04-18 mleich
#
--disable_warnings
drop temporary table if exists t1;
drop table if exists t1, t2;
drop procedure if exists p_verify_reprepare_count;
drop procedure if exists p1;
drop function if exists f1;
drop view if exists t1;
drop schema if exists mysqltest;
--enable_warnings
delimiter |;
create procedure p_verify_reprepare_count(expected int)
begin
declare old_reprepare_count int default @reprepare_count;
select variable_value from
information_schema.session_status where
variable_name='com_stmt_reprepare'
into @reprepare_count;
if old_reprepare_count + expected <> @reprepare_count then
select concat("Expected: ", expected,
", actual: ", @reprepare_count - old_reprepare_count)
as "ERROR";
else
select '' as "SUCCESS";
end if;
end|
delimiter ;|
set @reprepare_count= 0;
flush status;
--disable_warnings
drop table if exists t1;
--disable_warnings
--echo # Column added or dropped is not within the list of selected columns
--echo # or table comment has changed.
--echo # A reprepare is probably not needed.
create table t1 (a int, b int);
prepare stmt from "select a from t1";
execute stmt;
call p_verify_reprepare_count(0);
alter table t1 add column c int;
execute stmt;
call p_verify_reprepare_count(1);
execute stmt;
call p_verify_reprepare_count(0);
alter table t1 drop column b;
execute stmt;
call p_verify_reprepare_count(1);
execute stmt;
call p_verify_reprepare_count(0);
alter table t1 comment "My best table";
execute stmt;
call p_verify_reprepare_count(1);
execute stmt;
call p_verify_reprepare_count(0);
drop table t1;
deallocate prepare stmt;
--echo # Selects using the table at various positions, inser,update ...
--echo # + the table disappears
create table t1 (a int);
# Attention:
# "truncate" must have the first position (= executed as last prepared
# statement), because it recreates the table which has leads to reprepare
# (is this really needed) of all statements.
prepare stmt1 from "truncate t1";
prepare stmt2 from "select 1 as my_column from t1";
prepare stmt3 from "select 1 as my_column from (select * from t1) as t2";
prepare stmt4 from
"select 1 as my_column from (select 1) as t2 where exists (select 1 from t1)";
prepare stmt5 from "select * from (select 1 as b) as t2, t1";
prepare stmt6 from "select * from t1 union all select 1.5";
prepare stmt7 from "select 1 as my_column union all select 1 from t1";
prepare stmt8 from "insert into t1 values(1),(2)";
prepare stmt9 from "update t1 set a = 3 where a = 2";
prepare stmt10 from "delete from t1 where a = 1";
let ps_stmt_count= 10;
--echo # Attention: Result logging is disabled.
# Checks of correct results of statements are not the goal of this test.
let $num= $ps_stmt_count;
while ($num)
{
--disable_result_log
eval execute stmt$num;
--enable_result_log
dec $num;
}
# There was no reprepare needed, because none of the objects has changed.
call p_verify_reprepare_count(0);
drop table t1;
let $num= $ps_stmt_count;
while ($num)
{
--error ER_NO_SUCH_TABLE
eval execute stmt$num;
dec $num;
}
# There was no reprepare needed, because the statement is no more applicable.
call p_verify_reprepare_count(0);
let $num= $ps_stmt_count;
while ($num)
{
eval deallocate prepare stmt$num;
dec $num;
}
--echo # Selects using the table at various positions, inser,update ...
--echo # + layout change (drop column) which must cause a reprepare
create table t1 (a int, b int);
insert into t1 values(1,1),(2,2),(3,3);
create table t2 like t1;
insert into t1 values(2,2);
prepare stmt1 from "select a,b from t1";
prepare stmt2 from "select a,b from (select * from t1) as t1";
prepare stmt3 from "select * from t1 where a = 2 and b = 2";
prepare stmt4 from "select * from t2 where (a,b) in (select * from t1)";
prepare stmt5 from "select * from t1 union select * from t2";
prepare stmt6 from "select * from t1 union all select * from t2";
prepare stmt7 from "insert into t1 set a = 4, b = 4";
prepare stmt8 from "insert into t1 select * from t2";
let ps_stmt_count= 8;
--echo # Attention: Result logging is disabled.
# Checks of correct results of statements are not the goal of this test.
let $num= $ps_stmt_count;
while ($num)
{
--disable_result_log
eval execute stmt$num;
--enable_result_log
dec $num;
}
call p_verify_reprepare_count(0);
alter table t1 drop column b;
--disable_abort_on_error
let $num= $ps_stmt_count;
while ($num)
{
eval execute stmt$num;
# A reprepare is needed, because layout change of t1 affects statement.
call p_verify_reprepare_count(1);
dec $num;
}
let $num= $ps_stmt_count;
while ($num)
{
eval execute stmt$num;
call p_verify_reprepare_count(1);
dec $num;
}
--echo # Why does the INSERT ... SELECT does not get a reprepare or is
--echo # only the counter not incremented?
eval execute stmt8;
call p_verify_reprepare_count(1);
--enable_abort_on_error
alter table t2 add column c int;
--error ER_WRONG_VALUE_COUNT_ON_ROW
eval execute stmt8;
call p_verify_reprepare_count(1);
let $num= $ps_stmt_count;
while ($num)
{
eval deallocate prepare stmt$num;
dec $num;
}
drop table t1;
drop table t2;
--echo # select AVG(<col>) + optimizer uses index meets loss of the index
create table t1 (a int, b int, primary key(b),unique index t1_unq_idx(a));
# We need an index which is not converted to PRIMARY KEY (becomes in
# case of InnoDB the key used for table clustering).
insert into t1 set a = 0, b = 0;
insert into t1 select a + 1, b + 1 from t1;
insert into t1 select a + 2, b + 2 from t1;
insert into t1 select a + 4, b + 4 from t1;
insert into t1 select a + 8, b + 8 from t1;
# "using index" optimizer strategy is intended
let $possible_keys=
query_get_value(explain select avg(a) from t1, possible_keys, 1);
let $extra=
query_get_value(explain select avg(a) from t1, Extra, 1);
--echo # Optimizer strategy: Possible keys = $possible_keys , Extra = $extra
prepare stmt from "select avg(a) from t1";
execute stmt;
call p_verify_reprepare_count(0);
execute stmt;
call p_verify_reprepare_count(0);
alter table t1 drop index t1_unq_idx;
let $possible_keys=
query_get_value(explain select avg(a) from t1, possible_keys, 1);
let $extra=
query_get_value(explain select avg(a) from t1, Extra, 1);
--echo # Optimizer strategy: Possible keys = $possible_keys , Extra = $extra
execute stmt;
call p_verify_reprepare_count(1);
execute stmt;
call p_verify_reprepare_count(0);
--echo # select AVG(<col>) + optimizer uses table scan meets a new index
alter table t1 add unique index t1_unq_idx(a);
let $possible_keys=
query_get_value(explain select avg(a) from t1, possible_keys, 1);
let $extra=
query_get_value(explain select avg(a) from t1, Extra, 1);
--echo # Optimizer strategy: Possible keys = $possible_keys , Extra = $extra
execute stmt;
call p_verify_reprepare_count(1);
execute stmt;
call p_verify_reprepare_count(0);
deallocate prepare stmt;
drop table t1;
--echo # table replaced by not updatable view - Insert
create table t1 (a int);
prepare stmt from "insert into t1 values(1)";
execute stmt;
call p_verify_reprepare_count(0);
drop table t1;
create view t1 as select 1;
--error ER_NON_INSERTABLE_TABLE
execute stmt;
call p_verify_reprepare_count(1);
drop view t1;
create table t2 (a int);
create view t1 as select * from t2 with check option;
execute stmt;
call p_verify_reprepare_count(1);
execute stmt;
call p_verify_reprepare_count(0);
select * from t1;
deallocate prepare stmt;
drop view t1;
drop table t2;
--echo =====================================================================
--echo Some freestyle tests
--echo =====================================================================
create temporary table t1 as select 1 as a;
delimiter |;
create procedure p1()
begin
drop temporary table t1;
end|
create function f1() returns int
begin
call p1();
return 1;
end|
delimiter ;|
prepare stmt from "select f1() as my_column, a from t1";
--error ER_CANT_REOPEN_TABLE
execute stmt;
call p_verify_reprepare_count(0);
select * from t1;
prepare stmt from "select a, f1() as my_column from t1";
--error ER_CANT_REOPEN_TABLE
execute stmt;
call p_verify_reprepare_count(0);
select * from t1;
prepare stmt from "select f1() as my_column, count(*) from t1";
--error ER_CANT_REOPEN_TABLE
execute stmt;
call p_verify_reprepare_count(0);
select * from t1;
prepare stmt from "select count(*), f1() as my_column from t1";
--error ER_CANT_REOPEN_TABLE
execute stmt;
call p_verify_reprepare_count(0);
select * from t1;
--echo # Execute fails, no drop of temporary table
prepare stmt from "select 1 as my_column from (select 1) as t2
where exists (select f1() from t1)";
execute stmt;
call p_verify_reprepare_count(0);
execute stmt;
call p_verify_reprepare_count(0);
select * from t1;
--echo # Execute drops temporary table
prepare stmt from "select f1()";
execute stmt;
call p_verify_reprepare_count(0);
--error ER_BAD_TABLE_ERROR
execute stmt;
call p_verify_reprepare_count(0);
drop function f1;
drop procedure p1;
deallocate prepare stmt;
--echo # Execute fails, temporary table is not replaced by another
create temporary table t1 as select 1 as a;
delimiter |;
create procedure p1()
begin
drop temporary table t1;
create temporary table t1 as select 'abc' as a;
end|
create function f1() returns int
begin
call p1();
return 1;
end|
delimiter ;|
prepare stmt from "select count(*), f1() as my_column from t1";
--error ER_CANT_REOPEN_TABLE
execute stmt;
call p_verify_reprepare_count(0);
select * from t1;
deallocate prepare stmt;
prepare stmt from "call p1";
execute stmt;
drop procedure p1;
create schema mysqltest;
delimiter |;
create procedure mysqltest.p1()
begin
drop schema mysqltest;
create schema mysqltest;
end|
delimiter ;|
--error ER_SP_DOES_NOT_EXIST
execute stmt;
call p_verify_reprepare_count(0);
--error ER_SP_DOES_NOT_EXIST
execute stmt;
call p_verify_reprepare_count(0);
deallocate prepare stmt;
drop schema mysqltest;
drop temporary table t1;
# Bug#36089 drop temp table in SP called by function, crash
# Note: A non prepared "select 1 from t1 having count(*) = f1();" is sufficient.
if (0)
{
create temporary table t1 as select 1 as a;
prepare stmt from "select 1 from t1 having count(*) = f1()";
execute stmt;
call p_verify_reprepare_count(0);
deallocate prepare stmt;
drop temporary table t1;
}
--echo # Cleanup
--echo #
--disable_warnings
drop temporary table if exists t1;
drop table if exists t1, t2;
drop procedure if exists p_verify_reprepare_count;
drop procedure if exists p1;
drop function if exists f1;
drop view if exists t1;
drop schema if exists mysqltest;
--enable_warnings

View File

@ -25,6 +25,15 @@ while ($1)
}
--enable_warnings
#
# In order for the test to pass in --ps-protocol, we must
# set table_definition_cache size to at least 258 elements.
# Otherwise table versions are bound to change between
# prepare and execute, and we will get a constant validation
# error. See WL#4165 for details.
#
set @save_table_definition_cache= @@global.table_definition_cache;
set @@global.table_definition_cache=512;
create table t00 (a int) engine=MERGE UNION=(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t257) INSERT_METHOD=FIRST;
enable_query_log;
select count(*) from t00;
@ -36,5 +45,6 @@ show status like "Qcache_queries_in_cache";
drop table t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t257,t00;
SET @@global.query_cache_size=0;
set @@global.table_definition_cache=@save_table_definition_cache;
# End of 4.1 tests

View File

@ -997,11 +997,10 @@ call p1();
# Altering trigger forcing it use different set of tables
drop trigger t1_bi;
create trigger t1_bi after insert on t1 for each row insert into t3 values (new.id);
# Until we implement proper mechanism for invalidation of PS/SP when table
# or SP's are changed these two statements will fail with 'Table ... was
# not locked' error (this mechanism should be based on the new TDC).
--error ER_NO_SUCH_TABLE
execute stmt1;
# Until we implement proper mechanism for invalidation of SP statements
# invoked whenever a table used in SP changes, this statement will fail with
# 'Table ... does not exist' error.
--error ER_NO_SUCH_TABLE
call p1();
deallocate prepare stmt1;

View File

@ -778,3 +778,20 @@ set global thread_cache_size =@my_thread_cache_size;
--replace_column 2 #
show global variables where Variable_name='table_definition_cache' or
Variable_name='table_lock_wait_timeout';
###########################################################################
--echo
--echo # --
--echo # -- Bug#34820: log_output can be set to illegal value.
--echo # --
--error ER_WRONG_VALUE_FOR_VAR
SET GLOBAL log_output = '';
--error ER_WRONG_VALUE_FOR_VAR
SET GLOBAL log_output = 0;
--echo
--echo # -- End of Bug#34820.