~vkolesnikov/pbxt/pbxt-preload-test-bug

« back to all changes in this revision

Viewing changes to pbxt/mysql-test-update/mysql-test/t/ps.test

  • Committer: paul-mccullagh
  • Date: 2008-03-10 11:36:34 UTC
  • Revision ID: paul-mccullagh-417ebf175a9c8ee6e5b3777d9e2398e1fb197391
Implemented full durability

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
-- source include/not_embedded.inc
 
2
-- source include/have_log_bin.inc
2
3
#
3
4
# SQL Syntax for Prepared Statements test
4
5
#
34
35
execute stmt1;
35
36
 
36
37
# Nesting ps commands is not allowed: 
37
 
--error 1064
 
38
--error ER_UNSUPPORTED_PS 
38
39
prepare stmt2 from 'prepare nested_stmt from "select 1"';
39
40
 
40
 
--error 1064
 
41
--error ER_UNSUPPORTED_PS 
41
42
prepare stmt2 from 'execute stmt1';
42
43
 
43
 
--error 1064
 
44
--error ER_UNSUPPORTED_PS 
44
45
prepare stmt2 from 'deallocate prepare z';
45
46
 
46
47
# PS insert 
400
401
#
401
402
create database mysqltest1;
402
403
create table t1 (a int);
403
 
create table mysqltest1.t1 (a int) engine=myisam; # PBXT, the SELECT below references 2 databases
 
404
create table mysqltest1.t1 (a int) engine=myisam; # PBXT, the SELECT below references 2 databases;
404
405
select * from t1, mysqltest1.t1;
405
406
prepare stmt from "select * from t1, mysqltest1.t1";
406
407
execute stmt;
1118
1119
DEALLOCATE PREPARE stmt;
1119
1120
DROP TABLE t1;
1120
1121
 
 
1122
#
 
1123
# Bug#19182: CREATE TABLE bar (m INT) SELECT n FROM foo; doesn't work
 
1124
# from stored procedure.
 
1125
#
 
1126
# The cause of a bug was that cached LEX::create_list was modified,
 
1127
# and then together with LEX::key_list was reset.
 
1128
#
 
1129
--disable_warnings
 
1130
DROP TABLE IF EXISTS t1, t2;
 
1131
--enable_warnings
 
1132
 
 
1133
CREATE TABLE t1 (i INT);
 
1134
 
 
1135
PREPARE st_19182
 
1136
FROM "CREATE TABLE t2 (i INT, j INT, KEY (i), KEY(j)) SELECT i FROM t1";
 
1137
 
 
1138
EXECUTE st_19182;
 
1139
DESC t2;
 
1140
 
 
1141
DROP TABLE t2;
 
1142
 
 
1143
# Check that on second execution we don't loose 'j' column and the keys
 
1144
# on 'i' and 'j' columns.
 
1145
EXECUTE st_19182;
 
1146
DESC t2;
 
1147
 
 
1148
DEALLOCATE PREPARE st_19182;
 
1149
DROP TABLE t2, t1;
 
1150
 
 
1151
#
 
1152
# Bug #22060 "ALTER TABLE x AUTO_INCREMENT=y in SP crashes server"
 
1153
#
 
1154
# Code which implemented CREATE/ALTER TABLE and CREATE DATABASE
 
1155
# statement modified HA_CREATE_INFO structure in LEX, making these
 
1156
# statements PS/SP-unsafe (their re-execution might have resulted
 
1157
# in incorrect results).
 
1158
#
 
1159
--disable_warnings
 
1160
drop database if exists mysqltest;
 
1161
drop table if exists t1, t2;
 
1162
--enable_warnings
 
1163
# CREATE TABLE and CREATE TABLE ... SELECT
 
1164
create database mysqltest character set utf8;
 
1165
prepare stmt1 from "create table mysqltest.t1 (c char(10))";
 
1166
prepare stmt2 from "create table mysqltest.t2 select 'test'";
 
1167
execute stmt1;
 
1168
execute stmt2;
 
1169
show create table mysqltest.t1;
 
1170
show create table mysqltest.t2;
 
1171
drop table mysqltest.t1;
 
1172
drop table mysqltest.t2;
 
1173
alter database mysqltest character set latin1;
 
1174
execute stmt1;
 
1175
execute stmt2;
 
1176
show create table mysqltest.t1;
 
1177
show create table mysqltest.t2;
 
1178
drop database mysqltest;
 
1179
deallocate prepare stmt1;
 
1180
deallocate prepare stmt2;
 
1181
#
 
1182
# CREATE TABLE with DATA DIRECTORY option
 
1183
#
 
1184
# Protect ourselves from data left in tmp/ by a previos possibly failed
 
1185
# test
 
1186
--system rm -f $MYSQLTEST_VARDIR/tmp/t1.*
 
1187
--disable_warnings
 
1188
--disable_query_log
 
1189
eval prepare stmt from "create table t1 (c char(10)) data directory='$MYSQLTEST_VARDIR/tmp'";
 
1190
--enable_query_log
 
1191
execute stmt;
 
1192
#
 
1193
# DATA DIRECTORY option does not always work: if the operating
 
1194
# system does not support symlinks, have_symlinks option is automatically
 
1195
# disabled.
 
1196
# In this case DATA DIRECTORY is silently ignored when
 
1197
# creating a table, and is not output by SHOW CREATE TABLE.
 
1198
#
 
1199
--disable_result_log
 
1200
show create table t1;
 
1201
--enable_result_log
 
1202
drop table t1;
 
1203
execute stmt;
 
1204
--disable_result_log
 
1205
show create table t1;
 
1206
--enable_result_log
 
1207
--enable_warnings
 
1208
drop table t1;
 
1209
deallocate prepare stmt;
 
1210
#
 
1211
 
 
1212
#
 
1213
# Bug #27937: crash on the second execution for prepared statement 
 
1214
#             from UNION with ORDER BY an expression containing RAND()
 
1215
#
 
1216
 
 
1217
CREATE TABLE t1(a int);
 
1218
INSERT INTO t1 VALUES (2), (3), (1);
 
1219
 
 
1220
PREPARE st1 FROM
 
1221
  '(SELECT a FROM t1) UNION (SELECT a+10 FROM t1) ORDER BY RAND()*0+a';
 
1222
 
 
1223
EXECUTE st1;
 
1224
EXECUTE st1;
 
1225
 
 
1226
DEALLOCATE PREPARE st1;
 
1227
DROP TABLE t1;
 
1228
 
1121
1229
--echo End of 4.1 tests.
1122
1230
 
1123
 
 
1124
1231
############################# 5.0 tests start ################################
1125
1232
#
1126
1233
#
1358
1465
#
1359
1466
create database mysqltest_long_database_name_to_thrash_heap;
1360
1467
use test;
1361
 
create table t1 (i int);
 
1468
create table t1 (i int) engine=myisam; # PBXT: Cannot rename over database boundary
1362
1469
prepare stmt from "alter table test.t1 rename t1";
1363
1470
use mysqltest_long_database_name_to_thrash_heap;
1364
1471
execute stmt;
1574
1681
deallocate prepare no_index;
1575
1682
deallocate prepare sq;
1576
1683
 
 
1684
 
1577
1685
#
1578
1686
# Bug 25027: query with a single-row non-correlated subquery
1579
1687
#            and IS NULL predicate
1596
1704
DEALLOCATE PREPARE stmt;
1597
1705
 
1598
1706
DROP TABLE t1,t2;
 
1707
#
 
1708
# Bug#4968 "Stored procedure crash if cursor opened on altered table"
 
1709
# The bug is not repeatable any more after the fix for
 
1710
# Bug#15217 "Bug #15217   Using a SP cursor on a table created with PREPARE
 
1711
# fails with weird error", however ALTER TABLE is not re-execution friendly
 
1712
# and that caused a valgrind warning. Check that the warning is gone.
 
1713
#
 
1714
--disable_warnings
 
1715
drop table if exists t1;
 
1716
--enable_warnings
 
1717
create table t1 (s1 char(20));
 
1718
prepare stmt from "alter table t1 modify s1 int";
 
1719
execute stmt;
 
1720
execute stmt;
 
1721
drop table t1;
 
1722
deallocate prepare stmt;
 
1723
 
 
1724
#
 
1725
# Bug#6895 "Prepared Statements: ALTER TABLE DROP COLUMN does nothing"
 
1726
#
 
1727
--disable_warnings
 
1728
drop table if exists t1;
 
1729
--enable_warnings
 
1730
create table t1 (a int, b int);
 
1731
prepare s_6895 from "alter table t1 drop column b";
 
1732
execute s_6895;
 
1733
show columns from t1;
 
1734
drop table t1;
 
1735
create table t1 (a int, b int);
 
1736
execute s_6895;
 
1737
show columns from t1;
 
1738
drop table t1;
 
1739
create table t1 (a int, b int);
 
1740
execute s_6895;
 
1741
show columns from t1;
 
1742
deallocate prepare s_6895;
 
1743
drop table t1;
 
1744
 
 
1745
#
 
1746
# Bug #22060 "ALTER TABLE x AUTO_INCREMENT=y in SP crashes server"
 
1747
#
 
1748
# 5.0 part of the test.
 
1749
#
 
1750
 
 
1751
# ALTER TABLE
 
1752
create table t1 (i int primary key auto_increment) comment='comment for table t1';
 
1753
create table t2 (i int, j int, k int);
 
1754
prepare stmt from "alter table t1 auto_increment=100";
 
1755
execute stmt;
 
1756
show create table t1;
 
1757
# Let us trash table-cache's memory
 
1758
flush tables;
 
1759
select * from t2;
 
1760
execute stmt;
 
1761
show create table t1;
 
1762
deallocate prepare stmt;
 
1763
drop table t1, t2;
 
1764
# 5.1 part of the test.
 
1765
# CREATE DATABASE
 
1766
set @old_character_set_server= @@character_set_server;
 
1767
set @@character_set_server= latin1; 
 
1768
prepare stmt from "create database mysqltest_1";
 
1769
execute stmt;
 
1770
show create database mysqltest_1;
 
1771
drop database mysqltest_1;
 
1772
set @@character_set_server= utf8; 
 
1773
execute stmt;
 
1774
show create database mysqltest_1;
 
1775
drop database mysqltest_1;
 
1776
deallocate prepare stmt;
 
1777
set @@character_set_server= @old_character_set_server;
 
1778
 
 
1779
 
 
1780
#
 
1781
# BUG#24491 "using alias from source table in insert ... on duplicate key"
 
1782
#
 
1783
--disable_warnings
 
1784
drop tables if exists t1;
 
1785
--enable_warnings
 
1786
create table t1 (id int primary key auto_increment, value varchar(10));
 
1787
insert into t1 (id, value) values (1, 'FIRST'), (2, 'SECOND'), (3, 'THIRD');
 
1788
# Let us prepare INSERT ... SELECT ... ON DUPLICATE KEY UPDATE statement
 
1789
# which in its ON DUPLICATE KEY clause erroneously tries to assign value
 
1790
# to a column which is mentioned only in SELECT part.
 
1791
prepare stmt from "insert into t1 (id, value) select * from (select 4 as i, 'FOURTH' as v) as y on duplicate key update v = 'DUP'";
 
1792
# Both first and second attempts to execute it should fail
 
1793
--error ER_BAD_FIELD_ERROR 
 
1794
execute stmt;
 
1795
--error ER_BAD_FIELD_ERROR
 
1796
execute stmt;
 
1797
deallocate prepare stmt;
 
1798
# And now the same test for more complex case which is more close
 
1799
# to the one that was reported originally.
 
1800
prepare stmt from "insert into t1 (id, value) select * from (select 4 as id, 'FOURTH' as value) as y on duplicate key update y.value = 'DUP'";
 
1801
--error ER_BAD_FIELD_ERROR 
 
1802
execute stmt;
 
1803
--error ER_BAD_FIELD_ERROR
 
1804
execute stmt;
 
1805
deallocate prepare stmt;
 
1806
drop tables t1;
 
1807
 
 
1808
#
 
1809
# Bug #28509: strange behaviour: passing a decimal value to PS
 
1810
#
 
1811
prepare stmt from "create table t1 select ?";
 
1812
set @a=1.0;
 
1813
execute stmt using @a;
 
1814
show create table t1;
 
1815
drop table t1;
1599
1816
 
1600
1817
--echo End of 5.0 tests.
1601
1818
 
1801
2018
select func_1(), func_1(), func_1() from dual;
1802
2019
drop function func_1;
1803
2020
drop procedure proc_1;
 
2021
 
 
2022
# make the output deterministic:
 
2023
# the order used in SHOW OPEN TABLES
 
2024
# is too much implementation dependent
 
2025
--disable_ps_protocol
1804
2026
flush tables;
1805
2027
select Host, User from mysql.user limit 0;
1806
2028
select Host, Db from mysql.host limit 0;
1807
2029
show open tables from mysql;
 
2030
--enable_ps_protocol
 
2031
 
1808
2032
prepare abc from "flush tables";
1809
2033
execute abc;
1810
2034
show open tables from mysql;
2144
2368
 
2145
2369
create procedure proc_1() install plugin my_plug soname 'some_plugin.so';
2146
2370
--replace_regex /(Can\'t open shared library).*$/\1/
2147
 
--error ER_CANT_OPEN_LIBRARY
2148
 
call proc_1();
2149
 
--replace_regex /(Can\'t open shared library).*$/\1/
2150
 
--error ER_CANT_OPEN_LIBRARY
2151
 
call proc_1();
2152
 
--replace_regex /(Can\'t open shared library).*$/\1/
2153
 
--error ER_CANT_OPEN_LIBRARY
 
2371
--error ER_CANT_OPEN_LIBRARY,ER_FEATURE_DISABLED
 
2372
call proc_1();
 
2373
--replace_regex /(Can\'t open shared library).*$/\1/
 
2374
--error ER_CANT_OPEN_LIBRARY,ER_FEATURE_DISABLED
 
2375
call proc_1();
 
2376
--replace_regex /(Can\'t open shared library).*$/\1/
 
2377
--error ER_CANT_OPEN_LIBRARY,ER_FEATURE_DISABLED
2154
2378
call proc_1();
2155
2379
drop procedure proc_1;
2156
2380
delimiter |;
2293
2517
#drop event xyz;
2294
2518
#drop procedure proc_1;
2295
2519
delimiter |;
2296
 
--error ER_EVENT_RECURSIVITY_FORBIDDEN
 
2520
--error ER_EVENT_RECURSION_FORBIDDEN
2297
2521
create function func_1() returns int begin create event xyz on schedule at now() do select 123; return 1; end|
2298
2522
delimiter ;|
2299
2523
--error ER_SP_DOES_NOT_EXIST
2485
2709
execute stmt2 using @to_format, @dec;
2486
2710
deallocate prepare stmt2;
2487
2711
 
 
2712
 
 
2713
#
 
2714
# BUG#18326: Do not lock table for writing during prepare of statement
 
2715
#
 
2716
--disable_warnings
 
2717
DROP TABLE IF EXISTS t1, t2;
 
2718
--enable_warnings
 
2719
 
 
2720
CREATE TABLE t1 (i INT);
 
2721
INSERT INTO t1 VALUES (1);
 
2722
CREATE TABLE t2 (i INT);
 
2723
INSERT INTO t2 VALUES (2);
 
2724
 
 
2725
LOCK TABLE t1 READ, t2 WRITE;
 
2726
 
 
2727
connect (conn1, localhost, root, , );
 
2728
 
 
2729
# Prepare never acquires the lock, and thus should not block.
 
2730
PREPARE stmt1 FROM "SELECT i FROM t1";
 
2731
PREPARE stmt2 FROM "INSERT INTO t2 (i) VALUES (3)";
 
2732
 
 
2733
# This should not block because READ lock on t1 is shared.
 
2734
EXECUTE stmt1;
 
2735
 
 
2736
# This should block because WRITE lock on t2 is exclusive.
 
2737
send EXECUTE stmt2;
 
2738
 
 
2739
connection default;
 
2740
 
 
2741
SELECT * FROM t2;
 
2742
UNLOCK TABLES;
 
2743
let $wait_condition= SELECT COUNT(*) = 2 FROM t2;
 
2744
--source include/wait_condition.inc
 
2745
SELECT * FROM t2;
 
2746
 
 
2747
# DDL and DML works even if some client have a prepared statement
 
2748
# referencing the table.
 
2749
ALTER TABLE t1 ADD COLUMN j INT;
 
2750
ALTER TABLE t2 ADD COLUMN j INT;
 
2751
INSERT INTO t1 VALUES (4, 5);
 
2752
INSERT INTO t2 VALUES (4, 5);
 
2753
 
 
2754
connection conn1;
 
2755
 
 
2756
reap;
 
2757
EXECUTE stmt1;
 
2758
EXECUTE stmt2;
 
2759
SELECT * FROM t2;
 
2760
 
 
2761
disconnect conn1;
 
2762
 
 
2763
connection default;
 
2764
 
 
2765
DROP TABLE t1, t2;
 
2766
 
 
2767
#
 
2768
# Bug #24879 Prepared Statements: CREATE TABLE (UTF8 KEY) produces a growing
 
2769
# key length
 
2770
#
 
2771
# Test that parse information is not altered by subsequent executions of a
 
2772
# prepared statement
 
2773
#
 
2774
drop table if exists t1;
 
2775
prepare stmt
 
2776
from "create table t1 (c char(100) character set utf8, key (c(10)))";
 
2777
execute stmt;
 
2778
show create table t1;
 
2779
drop table t1;
 
2780
execute stmt;
 
2781
show create table t1;
 
2782
drop table t1;
 
2783
 
 
2784
--echo End of 5.1 tests.