MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ps_modify1.inc
1 ###################### ps_modify1.inc ########################
2 # #
3 # Tests for prepared statements: big INSERT .. SELECTs #
4 # #
5 ##############################################################
6 
7 #
8 # NOTE: THESE TESTS CANNOT BE APPLIED TO TABLES OF TYPE MERGE.
9 # Test which can be applied to MERGE tables should be stored in
10 # include/ps_modify.inc .
11 #
12 
13 #
14 # NOTE: PLEASE SEE ps_1general.test (bottom)
15 # BEFORE ADDING NEW TEST CASES HERE !!!
16 
17 #
18 # Please be aware, that this file will be sourced by several test case files
19 # stored within the subdirectory 't'. So every change here will affect
20 # several test cases.
21 #
22 # Please do not modify the structure (DROP/ALTER..) of the tables
23 # 't1' and 't9'.
24 #
25 # But you are encouraged to use these two tables within your statements
26 # (DELETE/UPDATE/...) whenever possible.
27 # t1 - very simple table
28 # t9 - table with nearly all available column types
29 #
30 # The structure and the content of these tables can be found in
31 # include/ps_create.inc CREATE TABLE ...
32 # include/ps_renew.inc DELETE all rows and INSERT some rows
33 #
34 # Both tables are managed by the same storage engine.
35 # The type of the storage engine is stored in the variable '$type' .
36 
37 
38 
39 #------------------- Please insert your test cases here -------------------#
40 
41 
42 #-------- Please be very carefull when editing behind this line ----------#
43 
44 --source include/ps_renew.inc
45 #
46 # add a NULL row to t1: this row is used only in this test
47 insert into t1 values(0,NULL) ;
48 
49 ## big insert select statements
50 set @duplicate='duplicate ' ;
51 set @1000=1000 ;
52 set @5=5 ;
53 select a,b from t1 where a < 5 order by a ;
54 --enable_info
55 insert into t1 select a + @1000, concat(@duplicate,b) from t1
56 where a < @5 ;
57 --disable_info
58 select a,b from t1 where a >= 1000 order by a ;
59 delete from t1 where a >= 1000 ;
60 prepare stmt1 from ' insert into t1 select a + ?, concat(?,b) from t1
61 where a < ? ' ;
62 --enable_info
63 execute stmt1 using @1000, @duplicate, @5;
64 --disable_info
65 select a,b from t1 where a >= 1000 order by a ;
66 delete from t1 where a >= 1000 ;
67 
68 set @1=1 ;
69 set @2=2 ;
70 set @100=100 ;
71 set @float=1.00;
72 set @five='five' ;
73 --disable_warnings
74 drop table if exists t2;
75 --enable_warnings
76 create table t2 like t1 ;
77 --enable_info
78 insert into t2 (b,a)
79 select @duplicate, sum(first.a) from t1 first, t1 second
80  where first.a <> @5 and second.b = first.b
81  and second.b <> @five
82  group by second.b
83  having sum(second.a) > @2
84 union
85 select b, a + @100 from t1
86  where (a,b) in ( select sqrt(a+@1)+CAST(@float AS signed),b
87  from t1);
88 --disable_info
89 select a,b from t2 order by a ;
90 delete from t2 ;
91 prepare stmt1 from ' insert into t2 (b,a)
92 select ?, sum(first.a)
93  from t1 first, t1 second
94  where first.a <> ? and second.b = first.b and second.b <> ?
95  group by second.b
96  having sum(second.a) > ?
97 union
98 select b, a + ? from t1
99  where (a,b) in ( select sqrt(a+?)+CAST(? AS signed),b
100  from t1 ) ' ;
101 --enable_info
102 execute stmt1 using @duplicate, @5, @five, @2, @100, @1, @float ;
103 --disable_info
104 select a,b from t2 order by a ;
105 drop table t2;