mirror of
https://github.com/MariaDB/server.git
synced 2025-06-03 07:02:23 +03:00
Also some small fixes to make the PBXT testsuite work in --embedded. config/ac-macros/plugins.m4: MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS macro extended to support multiple files. mysql-test/std_data/pbxt_load_unique_error1.inc: Move file to be accessible also for testing embedded server. mysql-test/suite/pbxt/r/pbxt_bugs.result: Fix LOAD DATA LOCAL INFILE path so it works also for testing embedded server. mysql-test/suite/pbxt/t/pbxt_bugs.test: Fix LOAD DATA LOCAL INFILE path so it works also for testing embedded server. mysql-test/suite/pbxt/t/pbxt_locking.test: Disable for embedded, as it needs SHOW PROCESSLIST functionality not available there. mysql-test/suite/pbxt/t/pbxt_transactions.test: Disable test for embedded, as it needs ability to connect from outside (mysqldump). mysql-test/suite/pbxt/t/ps_1general.test: Fix replace_result for new mysql-test-run.pl. sql/sql_plugin.cc: Remove hack that disables PBXT in embedded. storage/pbxt/plug.in: Fix crash in PBXT in embedded server. storage/pbxt/src/Makefile.am: Remove not needed CFLAGS/CXXFLAGS (they cause autotools to generate different object names, which in turn cause the MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS replacement of object files inside library files not to work). storage/pbxt/src/ha_pbxt.cc: Ugly hack to allow more threads in embedded server (need a better fix I think). storage/pbxt/src/table_xt.cc: Use stderr for logging not stdout (prevent spamming --embedded test suite output with stray messages). storage/pbxt/src/thread_xt.cc: Use stderr for logging not stdout (prevent spamming --embedded test suite output with stray messages). storage/pbxt/src/trace_xt.cc: Use stderr for logging not stdout (prevent spamming --embedded test suite output with stray messages).
541 lines
12 KiB
Plaintext
541 lines
12 KiB
Plaintext
# We cannot run mysqldump against embedded server.
|
|
-- source include/not_embedded.inc
|
|
|
|
--disable_warnings
|
|
drop table if exists t1, t2, t3;
|
|
--enable_warnings
|
|
|
|
create table `t1` (`id` int( 11 ) not null ,primary key ( `id` )) engine = pbxt;
|
|
insert into `t1`values ( 1 ) ;
|
|
create table `t2` (`id` int( 11 ) not null default '0',unique key `id` ( `id` ) ,constraint `t1_id_fk` foreign key ( `id` ) references `t1` (`id` )) engine = pbxt;
|
|
insert into `t2`values ( 1 ) ;
|
|
create table `t3` (`id` int( 11 ) not null default '0',key `id` ( `id` ) ,constraint `t2_id_fk` foreign key ( `id` ) references `t2` (`id` )) engine = pbxt;
|
|
insert into `t3`values ( 1 ) ;
|
|
|
|
select * from t1;
|
|
select * from t2;
|
|
select * from t3;
|
|
|
|
--error 1451
|
|
update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
|
|
|
|
select * from t1;
|
|
select * from t2;
|
|
select * from t3;
|
|
|
|
--error 1451
|
|
delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
|
|
|
|
select * from t1;
|
|
select * from t2;
|
|
select * from t3;
|
|
|
|
--disable_warnings
|
|
drop table if exists t3, t2, t1;
|
|
--enable_warnings
|
|
|
|
create table t1 (id int primary key) engine = pbxt;
|
|
create table t2 (id int) engine = pbxt;
|
|
|
|
insert into t1 values ( 1 ) ;
|
|
insert into t1 values ( 2 ) ;
|
|
insert into t2 values ( 1 ) ;
|
|
insert into t2 values ( 2 ) ;
|
|
|
|
select * from t1;
|
|
select * from t2;
|
|
|
|
# This statement is returns an error calls ha_autocommit_or_rollback():
|
|
--error ER_DUP_ENTRY
|
|
update t1 set t1.id=1 where t1.id=2;
|
|
|
|
select * from t1;
|
|
select * from t2;
|
|
|
|
# This statement is returns no error and calls ha_autocommit_or_rollback():
|
|
update t1,t2 set t1.id=3, t2.id=3 where t1.id=2 and t2.id = t1.id;
|
|
|
|
select * from t1;
|
|
select * from t2;
|
|
|
|
# But this statement returns an error and does not call ha_autocommit_or_rollback():
|
|
--error ER_DUP_ENTRY
|
|
update t1,t2 set t1.id=1, t2.id=1 where t1.id=3 and t2.id = t1.id;
|
|
|
|
select * from t1;
|
|
select * from t2;
|
|
|
|
--error ER_DUP_ENTRY
|
|
update t1 set t1.id=1 where t1.id=3;
|
|
|
|
select * from t1;
|
|
select * from t2;
|
|
|
|
# rename will generate an error if MySQL thinks a transaction is
|
|
# still running.
|
|
|
|
--disable_warnings
|
|
drop table if exists t1, t2, t3;
|
|
--enable_warnings
|
|
|
|
create table t1 (c1 int);
|
|
insert t1 values (1);
|
|
select * from t1;
|
|
rename table t1 to t2;
|
|
|
|
# The select below will not include the data if the INSERT statement
|
|
# is not committed on time. By doing a SELECT FOR UPDATE, we
|
|
# make sure the SELECT transaction waits (I think)!
|
|
|
|
create table t1 (a text character set utf8, b text character set latin1);
|
|
insert t1 values (0x4F736E616272C3BC636B, 0x4BF66C6E);
|
|
select * from t1;
|
|
--exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ test
|
|
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/t1.sql
|
|
--exec $MYSQL_IMPORT test $MYSQLTEST_VARDIR/tmp/t1.txt
|
|
select * from t1 for update;
|
|
|
|
# Test nested start_stmt() calls
|
|
|
|
--disable_warnings
|
|
drop table if exists t1,t3;
|
|
--enable_warnings
|
|
create table t1 (
|
|
id char(16) not null default '',
|
|
data int not null
|
|
);
|
|
|
|
delimiter |;
|
|
|
|
insert into t1 values ("foo", 3), ("bar", 2), ("zip", 5), ("zap", 1)|
|
|
|
|
create table t3 (
|
|
v char(16) not null primary key,
|
|
c int unsigned not null
|
|
)|
|
|
|
|
create function getcount(s char(16)) returns int
|
|
begin
|
|
declare x int;
|
|
|
|
select count(*) into x from t3 where v = s;
|
|
if x = 0 then
|
|
insert into t3 values (s, 1);
|
|
else
|
|
update t3 set c = c+1 where v = s;
|
|
end if;
|
|
return x;
|
|
end|
|
|
|
|
select * from t1|
|
|
select * from t3|
|
|
|
|
select * from t1 where data = getcount("bar")|
|
|
|
|
select * from t1|
|
|
select * from t3|
|
|
|
|
drop table t1,t3|
|
|
|
|
delimiter ;|
|
|
|
|
drop function getcount;
|
|
|
|
# This test forces a begin transaction in start_stmt()
|
|
|
|
drop tables if exists t1;
|
|
create table t1 (id int);
|
|
lock tables t1 write;
|
|
insert t1 values (1);
|
|
insert t1 values (2);
|
|
select id from t1;
|
|
unlock tables;
|
|
select id from t1;
|
|
|
|
# This demonstratrates the behavior of locked tables
|
|
|
|
DROP TABLE if exists t1;
|
|
create table t1 (id int primary key);
|
|
insert t1 values (100);
|
|
LOCK TABLES t1 WRITE;
|
|
insert t1 values (98);
|
|
--error ER_DUP_ENTRY
|
|
insert into t1 values (99),(100);
|
|
select id from t1;
|
|
UNLOCK TABLES;
|
|
select id from t1;
|
|
|
|
# And this is how it goes with a transaction:
|
|
|
|
DROP TABLE if exists t1;
|
|
create table t1 (id int primary key);
|
|
insert t1 values (100);
|
|
begin;
|
|
insert t1 values (98);
|
|
--error ER_DUP_ENTRY
|
|
insert into t1 values (99),(100);
|
|
select id from t1;
|
|
rollback;
|
|
select id from t1;
|
|
|
|
|
|
# And this without lock or transaction:
|
|
|
|
DROP TABLE if exists t1;
|
|
create table t1 (id int primary key);
|
|
insert t1 values (100);
|
|
insert t1 values (98);
|
|
--error ER_DUP_ENTRY
|
|
insert into t1 values (99),(100);
|
|
select id from t1;
|
|
|
|
# And with multiple tables
|
|
|
|
DROP TABLE if exists t1, t2;
|
|
create table t1 (id int primary key);
|
|
insert t1 values (100);
|
|
create table t2 (id int primary key);
|
|
insert t2 values (100);
|
|
|
|
|
|
LOCK TABLES t1 WRITE, t2 READ;
|
|
insert t1 values (98);
|
|
select * from t1, t2 where t1.id = t2.id;
|
|
insert t1 values (97);
|
|
--error ER_DUP_ENTRY
|
|
insert into t1 values (99),(100);
|
|
select id from t1;
|
|
UNLOCK TABLES;
|
|
select id from t1;
|
|
|
|
DROP TABLE t1;
|
|
|
|
# Test ALTER TABLE and UPDATE together
|
|
|
|
--disable_warnings
|
|
drop table if exists t1, t2, t3;
|
|
--enable_warnings
|
|
create table t1 (a int, b int);
|
|
insert into t1 values (1, 2), (2, 3), (3, 4);
|
|
create table t2 (a int);
|
|
insert into t2 values (10), (20), (30);
|
|
create view v1 as select a as b, a/10 as a from t2;
|
|
|
|
connect (locker,localhost,root,,test);
|
|
connection locker;
|
|
lock table t1 write;
|
|
|
|
connect (changer,localhost,root,,test);
|
|
connection changer;
|
|
send alter table t1 add column c int default 100 after a;
|
|
|
|
connect (updater,localhost,root,,test);
|
|
connection updater;
|
|
sleep 2;
|
|
send update t1, v1 set t1.b=t1.a+t1.b+v1.b where t1.a=v1.a;
|
|
|
|
connection locker;
|
|
sleep 2;
|
|
unlock tables;
|
|
|
|
connection changer;
|
|
reap;
|
|
|
|
connection updater;
|
|
reap;
|
|
select * from t1;
|
|
select * from t2;
|
|
drop view v1;
|
|
drop table t1, t2;
|
|
|
|
# It is possible that the sweeper gets stuck because
|
|
#it has no dictionary information!
|
|
# As in the example below.
|
|
|
|
--disable_warnings
|
|
drop table if exists t1, t4;
|
|
--enable_warnings
|
|
|
|
create table t1 (
|
|
a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' '
|
|
) engine=pbxt;
|
|
|
|
insert t1 values ("a1", "a2", "b", "c", "d", "dummy");
|
|
|
|
create table t4 (
|
|
pk_col int auto_increment primary key, a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' '
|
|
) engine=pbxt;
|
|
|
|
insert into t4 (a1, a2, b, c, d, dummy) select * from t1;
|
|
|
|
create index idx12672_0 on t4 (a1);
|
|
create index idx12672_1 on t4 (a1,a2,b,c);
|
|
create index idx12672_2 on t4 (a1,a2,b);
|
|
analyze table t1;
|
|
|
|
# Rename between different databases if triggers exist should fail
|
|
use test;
|
|
--disable_warnings
|
|
drop table if exists t1;
|
|
drop database if exists mysqltest;
|
|
--enable_warnings
|
|
|
|
create database mysqltest;
|
|
use mysqltest;
|
|
create table t1 (id int);
|
|
create trigger t1_bi before insert on t1 for each row set @a:=new.id;
|
|
insert into t1 values (101);
|
|
--error ER_TRG_IN_WRONG_SCHEMA, 1005
|
|
alter table t1 rename to test.t1, add column val int default 0;
|
|
|
|
drop database mysqltest;
|
|
use test;
|
|
|
|
# Various update/statement boundary tests
|
|
|
|
create table t9 (id int primary key auto_increment, fk int, index (fk)) engine=pbxt;
|
|
insert into t9 (id) values (null),(null),(null),(null),(null);
|
|
update t9 set fk=69 where fk is null order by id limit 1;
|
|
SELECT * from t9;
|
|
drop table t9;
|
|
|
|
create table t9 (id int primary key auto_increment, fk int, index (fk)) engine=pbxt;
|
|
lock tables t9 write;
|
|
insert into t9 (id) values (null),(null),(null),(null),(null);
|
|
update t9 set fk=69 where fk is null order by id limit 1;
|
|
SELECT * from t9 order by id;
|
|
unlock tables;
|
|
SELECT * from t9 order by id;
|
|
drop table t9;
|
|
|
|
create table t9 (id int primary key auto_increment, fk int, index (fk)) engine=pbxt;
|
|
|
|
delimiter |;
|
|
|
|
create procedure auto_test()
|
|
begin
|
|
insert into t9 (id) values (null),(null),(null),(null),(null);
|
|
update t9 set fk=69 where fk is null order by id limit 1;
|
|
SELECT * from t9;
|
|
end|
|
|
|
|
delimiter ;|
|
|
|
|
call auto_test();
|
|
SELECT * from t9;
|
|
|
|
drop procedure auto_test;
|
|
drop table t9;
|
|
|
|
SET AUTOCOMMIT=0;
|
|
|
|
create table t9 (id int primary key auto_increment, fk int, index (fk)) engine=pbxt;
|
|
insert into t9 (id) values (null),(null),(null),(null),(null);
|
|
update t9 set fk=69 where fk is null order by id limit 1;
|
|
SELECT * from t9;
|
|
drop table t9;
|
|
|
|
create table t9 (id int primary key auto_increment, fk int, index (fk)) engine=pbxt;
|
|
lock tables t9 write;
|
|
insert into t9 (id) values (null),(null),(null),(null),(null);
|
|
update t9 set fk=69 where fk is null order by id limit 1;
|
|
SELECT * from t9;
|
|
unlock tables;
|
|
SELECT * from t9;
|
|
drop table t9;
|
|
|
|
create table t9 (id int primary key auto_increment, fk int, index (fk)) engine=pbxt;
|
|
|
|
delimiter |;
|
|
|
|
create procedure auto_test()
|
|
begin
|
|
insert into t9 (id) values (null),(null),(null),(null),(null);
|
|
update t9 set fk=69 where fk is null order by id limit 1;
|
|
SELECT * from t9;
|
|
end|
|
|
|
|
delimiter ;|
|
|
|
|
call auto_test();
|
|
SELECT * from t9;
|
|
|
|
drop procedure auto_test;
|
|
drop table t9;
|
|
|
|
SET AUTOCOMMIT=1;
|
|
|
|
SET AUTOCOMMIT=0;
|
|
|
|
create table t9 (id int primary key auto_increment, fk int, index (fk)) engine=pbxt;
|
|
insert into t9 (id) values (null),(null),(null),(null),(null);
|
|
update t9 set fk=69 where fk is null order by id limit 1;
|
|
SELECT * from t9;
|
|
commit;
|
|
SELECT * from t9;
|
|
drop table t9;
|
|
|
|
create table t9 (id int primary key auto_increment, fk int, index (fk)) engine=pbxt;
|
|
lock tables t9 write;
|
|
insert into t9 (id) values (null),(null),(null),(null),(null);
|
|
update t9 set fk=69 where fk is null order by id limit 1;
|
|
SELECT * from t9;
|
|
unlock tables;
|
|
SELECT * from t9;
|
|
commit;
|
|
SELECT * from t9;
|
|
drop table t9;
|
|
|
|
create table t9 (id int primary key auto_increment, fk int, index (fk)) engine=pbxt;
|
|
|
|
delimiter |;
|
|
|
|
create procedure auto_test()
|
|
begin
|
|
insert into t9 (id) values (null),(null),(null),(null),(null);
|
|
update t9 set fk=69 where fk is null order by id limit 1;
|
|
SELECT * from t9;
|
|
end|
|
|
|
|
delimiter ;|
|
|
|
|
call auto_test();
|
|
SELECT * from t9;
|
|
commit;
|
|
SELECT * from t9;
|
|
|
|
drop procedure auto_test;
|
|
drop table t9;
|
|
|
|
SET AUTOCOMMIT=1;
|
|
|
|
# Create table involving a procedure
|
|
# This tests the handling of transactions an statements
|
|
|
|
delimiter |;
|
|
|
|
--disable_warnings
|
|
drop table if exists t1,t3|
|
|
--enable_warnings
|
|
|
|
create table t1 (
|
|
id char(16) not null default '',
|
|
data int not null
|
|
)|
|
|
insert t1 value ("one", 1), ("two", 2)|
|
|
|
|
--disable_warnings
|
|
drop function if exists bug12472|
|
|
--enable_warnings
|
|
create function bug12472() returns int
|
|
begin
|
|
declare a int;
|
|
declare b int;
|
|
set a = (select count(*) from t1);
|
|
set b = (select count(*) from t1);
|
|
return (a + b);
|
|
end|
|
|
# Check case when function is used directly
|
|
create table t3 as select bug12472() as i|
|
|
show create table t3|
|
|
select * from t3|
|
|
drop table t3|
|
|
# Check case when function is used indirectly through view
|
|
create view v1 as select bug12472() as j|
|
|
create table t3 as select * from v1|
|
|
show create table t3|
|
|
select * from t3|
|
|
drop table t3|
|
|
drop view v1|
|
|
drop function bug12472|
|
|
|
|
drop table t1|
|
|
|
|
# Test procedures and transactions
|
|
|
|
--disable_warnings
|
|
drop table if exists t1, t3|
|
|
drop procedure if exists t3_update|
|
|
drop function if exists t3_update|
|
|
--enable_warnings
|
|
|
|
create table t3 (a smallint primary key) engine=pbxt|
|
|
|
|
insert into t3 (a) values (1)|
|
|
|
|
create procedure t3_update()
|
|
deterministic
|
|
begin
|
|
declare continue handler for 1062 -- ER_DUP_ENTRY
|
|
select 'Outer (bad)' as 't3_update';
|
|
|
|
begin
|
|
declare continue handler for 1062 -- ER_DUP_ENTRY
|
|
select 'Inner (good)' as 't3_update';
|
|
|
|
insert into t3 values (1);
|
|
end;
|
|
end|
|
|
|
|
call t3_update()|
|
|
|
|
begin|
|
|
call t3_update()|
|
|
commit|
|
|
|
|
--disable_warnings
|
|
drop table if exists t3|
|
|
drop procedure if exists t3_update|
|
|
drop function if exists t3_update|
|
|
--enable_warnings
|
|
|
|
create table t3 (a smallint primary key) engine=pbxt|
|
|
insert into t3 (a) values (40)|
|
|
insert into t3 (a) values (50)|
|
|
|
|
create function t3_update() returns int
|
|
begin
|
|
insert into t3 values (10);
|
|
insert into t3 values (40);
|
|
insert into t3 values (500);
|
|
return 100;
|
|
end|
|
|
|
|
select * from t3|
|
|
|
|
connect (conn1,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK)|
|
|
connect (conn2,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK)|
|
|
|
|
connection conn1|
|
|
|
|
begin|
|
|
insert into t3 values (10)|
|
|
|
|
connection conn2|
|
|
# This will hang (so use send - reap later)
|
|
send select t3_update()|
|
|
|
|
connection conn1|
|
|
# This should stop the hanger:
|
|
rollback|
|
|
|
|
connection conn2|
|
|
-- error 1062
|
|
reap|
|
|
select * from t3|
|
|
|
|
--disable_warnings
|
|
drop function t3_update|
|
|
drop table if exists t1, t2, t3, t4|
|
|
--enable_warnings
|
|
|
|
--disable_query_log
|
|
drop database pbxt|
|
|
--enable_query_log
|
|
|
|
disconnect conn1|
|
|
disconnect conn2|
|
|
|
|
delimiter ;|
|
|
|