mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / t / ps_1general.test
blob387b3ebdd050ba9f240c48ff7026db19e5833f68
1 ###################### ps_general.test #######################
2 #                                                            #
3 #   basic and miscellaneous tests for prepared statements    #
4 #                                                            #
5 ##############################################################
7 #    
8 # NOTE: PLEASE SEE THE DETAILED DESCRIPTION AT THE BOTTOM OF THIS FILE
9 #       BEFORE ADDING NEW TEST CASES HERE !!!
11 --disable_warnings
12 drop table if exists t5, t6, t7, t8;
13 drop database if exists mysqltest ;
15 # Cleanup from other tests
16 drop database if exists client_test_db;
17 drop database if exists testtets;
18 drop table if exists t1Aa,t2Aa,v1Aa,v2Aa;
19 drop view if exists t1Aa,t2Aa,v1Aa,v2Aa;
20 --enable_warnings
22 --disable_query_log
23 select '------ basic tests ------' as test_sequence ;
24 --enable_query_log
26 let $type= 'MYISAM' ;
27 # create the tables (t1 and t9) used in many tests
28 --source include/ps_create.inc
29 # insert data into these tables
30 --source include/ps_renew.inc
33 ################ The basic functions ################
35 # 1. PREPARE stmt_name FROM <preparable statement>;
36 #    <preparable statement> ::=
37 #     'literal_stmt' |
38 #     @variable_ref_stmt.
39 #    The statement may contain question marks as placeholders for parameters.
41 #    Bind a statement name to a string containing a SQL statement and
42 #    send it to the server. The server will parse the statement and
43 #    reply with "Query Ok" or an error message.
45 PREPARE stmt FROM ' select * from t1 where a = ? ' ;
47 # 2. EXECUTE stmt_name [USING @var [, @var ]];
48 #    Current values of supplied variables are used as parameters.
50 #    Send the server the order to execute the statement and supply values
51 #    for the input parameters needed.
52 #    If no error occurs the server reply will be identical to the reply for
53 #    the query used in PREPARE with question marks replaced with values of
54 #    the input variables.
56 SET @var= 2 ;
57 EXECUTE stmt USING @var ;
58 #    The non prepared statement with the same server reply would be:
59 select * from t1 where a = @var ;
61 # 3. DEALLOCATE PREPARE stmt_name;
63 #    Send the server the order to drop the parse informations.
64 #    The server will reply with "Query Ok" or an error message.
65 DEALLOCATE PREPARE stmt ;
67 ################ PREPARE ################
68 # prepare without parameter
69 prepare stmt1 from ' select 1 as my_col ' ;
70 # prepare with parameter
71 prepare stmt1 from ' select ? as my_col ' ;
72 # prepare must fail (incomplete statements/wrong syntax)
73 --error ER_PARSE_ERROR
74 prepare ;
75 --error ER_PARSE_ERROR
76 prepare stmt1 ;
77 --error ER_PARSE_ERROR
78 prepare stmt1 from ;
79 --error ER_PARSE_ERROR
80 prepare_garbage stmt1 from ' select 1 ' ;
81 --error ER_PARSE_ERROR
82 prepare stmt1 from_garbage ' select 1 ' ;
83 --error ER_PARSE_ERROR
84 prepare stmt1 from ' select_garbage 1 ' ;
85 --error ER_PARSE_ERROR
86 prepare from ' select 1 ' ;
87 --error ER_PARSE_ERROR
88 prepare stmt1 ' select 1 ' ;
89 --error ER_PARSE_ERROR
90 prepare ? from ' select ? as my_col ' ;
91 # statement in variable
92 set @arg00='select 1 as my_col';
93 prepare stmt1 from @arg00;
94 # prepare must fail (query variable is empty)
95 set @arg00='';
96 --error ER_EMPTY_QUERY
97 prepare stmt1 from @arg00;
98 set @arg00=NULL;
99 # prepare must fail (query variable is NULL)
100 --error ER_PARSE_ERROR
101 prepare stmt1 from @arg01;
103 prepare stmt1 from ' select * from t1 where a <= 2 ' ;
104 # prepare must fail (column x does not exist)
105 --error ER_BAD_FIELD_ERROR
106 prepare stmt1 from ' select * from t1 where x <= 2 ' ;
107 # cases derived from client_test.c: test_null()
108 # prepare must fail (column x does not exist)
109 --error ER_BAD_FIELD_ERROR
110 prepare stmt1 from ' insert into t1(a,x) values(?,?) ' ;
111 --error ER_BAD_FIELD_ERROR
112 prepare stmt1 from ' insert into t1(x,a) values(?,?) ' ;
113 --disable_warnings
114 drop table if exists not_exist ;
115 --enable_warnings
116 # prepare must fail (table does not exist)
117 --error ER_NO_SUCH_TABLE
118 prepare stmt1 from ' select * from not_exist where a <= 2 ' ;
120 # case derived from client_test.c: test_prepare_syntax()
121 # prepare must fail (incomplete statement)
122 --error ER_PARSE_ERROR
123 prepare stmt1 from ' insert into t1 values(? ' ;
124 --error ER_PARSE_ERROR
125 prepare stmt1 from ' select a, b from t1
126                      where a=? and where ' ;
128 ################ EXECUTE ################
129 # execute must fail (statement never_prepared never prepared)
130 --error ER_UNKNOWN_STMT_HANDLER
131 execute never_prepared ;
132 # execute must fail (prepare stmt1 just failed,
133 #         but there was a successful prepare of stmt1 before)
134 prepare stmt1 from ' select * from t1 where a <= 2 ' ;
135 --error ER_NO_SUCH_TABLE
136 prepare stmt1 from ' select * from not_exist where a <= 2 ' ;
137 --error ER_UNKNOWN_STMT_HANDLER
138 execute stmt1 ;
140 # drop the table between prepare and execute
141 create table t5
143   a int primary key,
144   b char(30),
145   c int
147 insert into t5( a, b, c) values( 1, 'original table', 1);
148 prepare stmt2 from ' select * from t5 ' ;
149 execute stmt2 ;
150 drop table t5 ;
151 # execute must fail (table was dropped after prepare)
152 --error ER_NO_SUCH_TABLE
153 execute stmt2 ;
154 # cases derived from client_test.c: test_select_prepare()
155 # 1. drop + create table (same column names/types/order) 
156 # between prepare and execute
157 create table t5
159   a int primary key,
160   b char(30),
161   c int
163 insert into t5( a, b, c) values( 9, 'recreated table', 9);
164 execute stmt2 ;
165 drop table t5 ;
166 # 2. drop + create table (same column names/types but different order)
167 # between prepare and execute
168 create table t5
170   a int primary key,
171   c int,
172   b char(30)
174 insert into t5( a, b, c) values( 9, 'recreated table', 9);
175 execute stmt2 ;
176 drop table t5 ;
177 # 3. drop + create table (same column names/types/order+extra column) 
178 # between prepare and execute
179 create table t5
181   a int primary key,
182   b char(30),
183   c int,
184   d timestamp default '2008-02-23 09:23:45'
186 insert into t5( a, b, c) values( 9, 'recreated table', 9);
187 execute stmt2 ;
188 drop table t5 ;
189 # 4. drop + create table (same column names/types, different order +
190 # additional column) between prepare and execute
191 create table t5
193   a int primary key,
194   d timestamp default '2008-02-23 09:23:45',
195   b char(30),
196   c int
198 insert into t5( a, b, c) values( 9, 'recreated table', 9);
199 execute stmt2 ;
200 drop table t5 ;
201 # 5. drop + create table (same column names/order, different types)
202 # between prepare and execute
203 create table t5
205   a timestamp default '2004-02-29 18:01:59',
206   b char(30),
207   c int
209 insert into t5( b, c) values( 'recreated table', 9);
210 execute stmt2 ;
211 drop table t5 ;
212 # 6. drop + create table (same column types/order, different names) 
213 # between prepare and execute
214 create table t5
216   f1 int primary key,
217   f2 char(30),
218   f3 int
220 insert into t5( f1, f2, f3) values( 9, 'recreated table', 9);
221 execute stmt2 ;
222 drop table t5 ;
224 # execute without parameter
225 prepare stmt1 from ' select * from t1 where a <= 2 ' ;
226 execute stmt1 ;
227 # execute with parameter
228 set @arg00=1 ;
229 set @arg01='two' ;
230 prepare stmt1 from ' select * from t1 where a <= ? ' ;
231 execute stmt1 using @arg00;
232 # execute must fail (too small number of parameters)
233 --error ER_WRONG_ARGUMENTS
234 execute stmt1 ;
235 # execute must fail (too big number of parameters)
236 --error ER_WRONG_ARGUMENTS
237 execute stmt1 using @arg00, @arg01;
238 # execute must fail (parameter is not set)
239 execute stmt1 using @not_set;
241 ################ DEALLOCATE ################
242 # deallocate must fail (the statement 'never_prepared' was never prepared)
243 --error ER_UNKNOWN_STMT_HANDLER
244 deallocate prepare never_prepared ;
245 # deallocate must fail (prepare stmt1 just failed,
246 #         but there was a successful prepare before)
247 prepare stmt1 from ' select * from t1 where a <= 2 ' ;
248 --error ER_NO_SUCH_TABLE
249 prepare stmt1 from ' select * from not_exist where a <= 2 ' ;
250 --error ER_UNKNOWN_STMT_HANDLER
251 deallocate prepare stmt1;
252 create table t5
254   a int primary key,
255   b char(10)
257 prepare stmt2 from ' select a,b from t5 where a <= 2 ' ;
258 drop table t5 ;
259 # deallocate prepared statement where the table was dropped after prepare
260 deallocate prepare stmt2;
262 ## parallel use of more than one prepared statement handlers
263 # switch between different queries
264 prepare stmt1 from ' select a from t1 where a <= 2 ' ;
265 prepare stmt2 from ' select b from t1 where a <= 2 ' ;
266 execute stmt2 ;
267 execute stmt1 ;
268 # switch between statement handlers of the same query
269 prepare stmt1 from ' select a from t1 where a <= 2 ' ;
270 prepare stmt2 from ' select a from t1 where a <= 2 ' ;
271 execute stmt2 ;
272 execute stmt1 ;
273 deallocate prepare stmt1 ;
274 # Will the deallocate of stmt1 with the same query affect stmt2 ?
275 execute stmt2 ;
277 --disable_query_log
278 select '------ show and misc tests ------' as test_sequence ;
279 --enable_query_log
281 --disable_warnings
282 drop table if exists t2;
283 --enable_warnings
284 create table t2 
286   a int primary key, b char(10)
289 ################ SHOW COMMANDS ################
290 prepare stmt4 from ' show databases ';
291 execute stmt4;
292 prepare stmt4 from ' show tables from test like ''t2%'' ';
293 execute stmt4;
294 prepare stmt4 from ' show columns from t2 where field in (select ?) ';
295 SET @arg00="a";
296 execute stmt4 using @arg00;
297 SET @arg00="b";
298 execute stmt4 using @arg00;
299 SET @arg00=1;
300 execute stmt4 using @arg00;
302 prepare stmt4 from ' show columns from t2 from test like ''a%'' ';
303 execute stmt4;
304 create index t2_idx on t2(b);
305 prepare stmt4 from ' show index from t2 from test ';
306 execute stmt4;
307 prepare stmt4 from ' show table status from test like ''t2%'' ';
308 # egalize date and time values
309 --replace_column 8 # 12 # 13 # 14 #
310 # Bug#4288 : prepared statement 'show table status ..', wrong output on execute
311 execute stmt4;
312 # try the same with the big table
313 prepare stmt4 from ' show table status from test like ''t9%'' ';
314 # egalize date and time values
315 --replace_column 8 # 12 # 13 # 14 #
316 # Bug#4288
317 execute stmt4;
318 prepare stmt4 from ' show status like ''Threads_running'' ';
319 --replace_column 2 #
320 execute stmt4;
321 prepare stmt4 from ' show variables like ''sql_mode'' ';
322 execute stmt4;
323 prepare stmt4 from ' show engine myisam logs ';
324 execute stmt4;
325 prepare stmt4 from ' show grants for user ';
326 prepare stmt4 from ' show create table t2 ';
327 prepare stmt4 from ' show master status ';
328 prepare stmt4 from ' show master logs ';
329 prepare stmt4 from ' show slave status ';
330 prepare stmt4 from ' show warnings limit 20 ';
331 prepare stmt4 from ' show errors limit 20 ';
332 prepare stmt4 from ' show storage engines ';
333 # The output depends upon the precise order in which
334 # storage engines are registered, so we switch off the output.
335 --disable_result_log
336 execute stmt4;
337 --enable_result_log
339 ################ MISC STUFF ################
340 ## get a warning and an error
341 # cases derived from client_test.c: test_warnings(), test_errors()
342 --disable_warnings
343 drop table if exists t5;
344 --enable_warnings
345 prepare stmt1 from ' drop table if exists t5 ' ;
346 execute stmt1 ;
347 prepare stmt1 from ' drop table t5 ' ;
348 --error ER_BAD_TABLE_ERROR
349 execute stmt1 ;
351 ## SELECT @@version
352 # cases derived from client_test.c: test_select_version()
354 # TODO: Metadata check is temporary disabled here, because metadata of 
355 # this statement also depends on @@version contents and you can't apply
356 # replace_column and replace_result to it. It will be enabled again when 
357 # support of replace_column and replace_result on metadata will be
358 # implemented.
360 #--enable_metadata
361 prepare stmt1 from ' SELECT @@version ' ;
362 # egalize the version
363 --replace_column 1 <version>
364 execute stmt1 ;
365 #--disable_metadata
367 ## do @var:= and set @var=
368 # cases derived from client_test.c: test_do_set()
369 prepare stmt_do from ' do @var:=  (1 in (select a from t1)) ' ;
370 prepare stmt_set from ' set @var= (1 in (select a from t1)) ' ;
371 let $1= 3 ;
372 while ($1)
374   execute stmt_do ;
375   --disable_query_log
376   select @var as 'content of @var is:' ;
377   --enable_query_log
378   execute stmt_set ;
379   --disable_query_log
380   select @var as 'content of @var is:' ;
381   --enable_query_log
382   dec $1 ;
384 # the same test with a table containing one column and 'select *'
385 --disable_warnings
386 drop table if exists t5 ;
387 --enable_warnings
388 create table t5 (a int) ;
389 prepare stmt_do from ' do @var:=  (1 in (select a from t5)) ' ;
390 prepare stmt_set from ' set @var= (1 in (select a from t5)) ' ;
391 let $1= 3 ;
392 while ($1)
394   execute stmt_do ;
395   --disable_query_log
396   select @var as 'content of @var is:' ;
397   --enable_query_log
398   execute stmt_set ;
399   --disable_query_log
400   select @var as 'content of @var is:' ;
401   --enable_query_log
402   dec $1 ;
404 drop table t5 ;
405 deallocate prepare stmt_do ;
406 deallocate prepare stmt_set ;
408 ## nonsense like prepare of prepare,execute or deallocate
409 --error ER_UNSUPPORTED_PS 
410 prepare stmt1 from ' prepare stmt2 from '' select 1 ''  ' ;
411 --error ER_UNSUPPORTED_PS 
412 prepare stmt1 from ' execute stmt2 ' ;
413 --error ER_UNSUPPORTED_PS 
414 prepare stmt1 from ' deallocate prepare never_prepared ' ;
416 ## We don't support alter view as prepared statements
417 --error ER_UNSUPPORTED_PS
418 prepare stmt1 from 'alter view v1 as select 2';
420 ## switch the database connection
421 --error ER_UNSUPPORTED_PS
422 prepare stmt4 from ' use test ' ;
424 ## create/drop database
425 prepare stmt3 from ' create database mysqltest ';
426 create database mysqltest ;
427 prepare stmt3 from ' drop database mysqltest ';
428 drop database mysqltest ;
430 #### table related commands
431 ## describe
432 prepare stmt3 from ' describe t2 ';
433 execute stmt3;
434 drop table t2 ;
435 --error ER_NO_SUCH_TABLE
436 execute stmt3;
437 ## lock/unlock
438 --error ER_UNSUPPORTED_PS
439 prepare stmt3 from ' lock tables t1 read ' ;
440 --error ER_UNSUPPORTED_PS
441 prepare stmt3 from ' unlock tables ' ;
442 ## Load/Unload table contents
444 --let $datafile = $MYSQLTEST_VARDIR/tmp/data.txt
445 --error 0,1
446 --remove_file $datafile
448 --replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
449 --error ER_UNSUPPORTED_PS
450 eval prepare stmt1 from ' load data infile ''$datafile''
451      into table t1 fields terminated by ''\t'' ';
452 --replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
453 eval prepare stmt1 from ' select * into outfile ''$datafile'' from t1 ';
454      execute stmt1 ;
455 ## 
456 prepare stmt1 from ' optimize table t1 ' ;
457 prepare stmt1 from ' analyze table t1 ' ;
458 prepare stmt1 from ' checksum table t1 ' ;
459 prepare stmt1 from ' repair table t1 ' ;
461 --replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
462 --error ER_UNSUPPORTED_PS
463 eval prepare stmt1 from ' restore table t1 from ''$datafile'' ' ;
464 --remove_file $datafile
466 ## handler
467 --error ER_UNSUPPORTED_PS
468 prepare stmt1 from ' handler t1 open ';
471 ## commit/rollback
472 prepare stmt3 from ' commit ' ;
473 prepare stmt3 from ' rollback ' ;
476 ## switch the sql_mode
477 prepare stmt4 from ' SET sql_mode=ansi ';
478 execute stmt4;
479 # check if the sql_mode is now ansi
480 select 'a' || 'b' ;
481 prepare stmt4 from ' SET sql_mode="" ';
482 execute stmt4;
483 # check if the sql_mode is not ansi
484 select '2' || '3' ;
485 # Will a switch of the sqlmode affect the execution of already prepared 
486 # statements ?
487 prepare stmt5 from ' select ''2'' || ''3'' ' ;
488 execute stmt5;
489 SET sql_mode=ansi;
490 execute stmt5;
491 SET sql_mode="";
493 prepare stmt1 from ' flush local privileges ' ;
494 prepare stmt1 from ' reset query cache ' ;
495 prepare stmt1 from ' KILL 0 ';
497 ## simple explain
498 # cases derived from client_test.c: test_explain_bug()
499 prepare stmt1 from ' explain select a from t1 order by b ';
500 # PS protocol gives slightly different metadata
501 --disable_ps_protocol
502 --enable_metadata
503 execute stmt1;
504 --disable_metadata
505 SET @arg00=1 ;
506 prepare stmt1 from ' explain select a from t1 where a > ? order by b ';
507 --enable_metadata
508 execute stmt1 using @arg00;
509 --disable_metadata
510 --enable_ps_protocol
512 ## parameters with probably problematic characters (quote, double  quote)
513 # cases derived from client_test.c: test_logs()
514 # try if 
515 --disable_warnings
516 drop table if exists t2;
517 --enable_warnings
518 create table t2 (id smallint, name varchar(20)) ;
519 prepare stmt1 from ' insert into t2 values(?, ?) ' ;
520 set @id= 9876 ;
521 set @arg00= 'MySQL - Open Source Database' ;
522 set @arg01= "'" ;
523 set @arg02= '"' ;
524 set @arg03= "my'sql'" ;
525 set @arg04= 'my"sql"' ;
526 insert into t2 values ( @id , @arg00 );
527 insert into t2 values ( @id , @arg01 );
528 insert into t2 values ( @id , @arg02 );
529 insert into t2 values ( @id , @arg03 );
530 insert into t2 values ( @id , @arg04 );
531 prepare stmt1 from ' select * from t2 where id= ? and name= ? ';
532 execute stmt1 using @id, @arg00 ;
533 execute stmt1 using @id, @arg01 ;
534 execute stmt1 using @id, @arg02 ;
535 execute stmt1 using @id, @arg03 ;
536 execute stmt1 using @id, @arg04 ;
537 drop table t2;
539 ################ CREATE/DROP/ALTER/RENAME TESTS ################
540 --disable_query_log
541 select '------ create/drop/alter/rename tests ------' as test_sequence ;
542 --enable_query_log
544 --disable_warnings
545 drop table if exists t2, t3;
546 --enable_warnings
548 ## DROP TABLE
549 prepare stmt_drop from ' drop table if exists t2 ' ;
550 --disable_warnings
551 execute stmt_drop;
552 --enable_warnings
554 ## CREATE TABLE
555 prepare stmt_create from ' create table t2 (
556                              a int primary key, b char(10)) ';
557 execute stmt_create;
558 prepare stmt3 from ' create table t3 like t2 ';
559 execute stmt3;
560 drop table t3;
562 ## CREATE TABLE .. SELECT
563 set @arg00=1;
564 prepare stmt3 from ' create table t3 (m int) select ? as m ' ;
565 # Bug#4280 server hangs, prepared "create table .. as select ? .."
566 execute stmt3 using @arg00;
567 select m from t3;
568 drop table t3;
570 prepare stmt3 from ' create index t2_idx on t2(b) ';
571 prepare stmt3 from ' drop index t2_idx on t2 ' ; 
572 prepare stmt3 from ' alter table t2 drop primary key ';
574 ## RENAME TABLE
575 --disable_warnings
576 drop table if exists new_t2;
577 --enable_warnings
578 prepare stmt3 from ' rename table t2 to new_t2 ';
579 execute stmt3;
580 --error ER_TABLE_EXISTS_ERROR
581 execute stmt3;
582 rename table new_t2 to t2;
583 drop table t2;
584 ## RENAME more than on TABLE within one statement
585 # cases derived from client_test.c: test_rename()
586 prepare stmt1 from ' rename table t5 to t6, t7 to t8 ' ;
587 create table t5 (a int) ;
588 # rename must fail, t7 does not exist
589 # Clean up the filename here because embedded server reports whole path
590 --replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' t7.frm t7
591 --error ER_FILE_NOT_FOUND
592 execute stmt1 ;
593 create table t7 (a int) ;
594 # rename, t5 -> t6 and t7 -> t8
595 execute stmt1 ;
596 # rename must fail, t5 and t7 does not exist t6 and t8 already exist
597 --error ER_TABLE_EXISTS_ERROR
598 execute stmt1 ;
599 rename table t6 to t5, t8 to t7 ;
600 # rename, t5 -> t6 and t7 -> t8
601 execute stmt1 ;
602 drop table t6, t8 ;
605 ################ BIG STATEMENT TESTS ################
606 --disable_query_log
607 select '------ big statement tests ------' as test_sequence ;
608 --enable_query_log
609 # The following tests use huge numbers of lines, characters or parameters
610 # per prepared statement.
611 # I assume the server and also the client (mysqltest) are stressed.
613 # Attention: The limits used are NOT derived from the manual
614 #            or other sources.
616 ## many lines ( 50 )
617 let $my_stmt= select 'ABC' as my_const_col from t1 where
618 1 = 1 AND
619 1 = 1 AND
620 1 = 1 AND
621 1 = 1 AND
622 1 = 1 AND
623 1 = 1 AND
624 1 = 1 AND
625 1 = 1 AND
626 1 = 1 AND
627 1 = 1 AND
628 1 = 1 AND
629 1 = 1 AND
630 1 = 1 AND
631 1 = 1 AND
632 1 = 1 AND
633 1 = 1 AND
634 1 = 1 AND
635 1 = 1 AND
636 1 = 1 AND
637 1 = 1 AND
638 1 = 1 AND
639 1 = 1 AND
640 1 = 1 AND
641 1 = 1 AND
642 1 = 1 AND
643 1 = 1 AND
644 1 = 1 AND
645 1 = 1 AND
646 1 = 1 AND
647 1 = 1 AND
648 1 = 1 AND
649 1 = 1 AND
650 1 = 1 AND
651 1 = 1 AND
652 1 = 1 AND
653 1 = 1 AND
654 1 = 1 AND
655 1 = 1 AND
656 1 = 1 AND
657 1 = 1 AND
658 1 = 1 AND
659 1 = 1 AND
660 1 = 1 AND
661 1 = 1 AND
662 1 = 1 AND
663 1 = 1 AND
664 1 = 1 AND
665 1 = 1 AND
666 1 = 1 ;
667 eval ($my_stmt) ;
668 eval prepare stmt1 from "$my_stmt" ;
669 execute stmt1 ;
670 execute stmt1 ;
672 ## many characters ( about 1400 )
674 let $my_stmt= select 'ABC' as my_const_col FROM t1 WHERE
675 '1234567890123456789012345678901234567890123456789012345678901234567890'
676 = '1234567890123456789012345678901234567890123456789012345678901234567890' AND
677 '1234567890123456789012345678901234567890123456789012345678901234567890'
678 = '1234567890123456789012345678901234567890123456789012345678901234567890' AND
679 '1234567890123456789012345678901234567890123456789012345678901234567890'
680 = '1234567890123456789012345678901234567890123456789012345678901234567890' AND
681 '1234567890123456789012345678901234567890123456789012345678901234567890'
682 = '1234567890123456789012345678901234567890123456789012345678901234567890' AND
683 '1234567890123456789012345678901234567890123456789012345678901234567890'
684 = '1234567890123456789012345678901234567890123456789012345678901234567890' AND
685 '1234567890123456789012345678901234567890123456789012345678901234567890'
686 = '1234567890123456789012345678901234567890123456789012345678901234567890' AND
687 '1234567890123456789012345678901234567890123456789012345678901234567890'
688 = '1234567890123456789012345678901234567890123456789012345678901234567890' AND
689 '1234567890123456789012345678901234567890123456789012345678901234567890'
690 = '1234567890123456789012345678901234567890123456789012345678901234567890' AND
691 '1234567890123456789012345678901234567890123456789012345678901234567890'
692 = '1234567890123456789012345678901234567890123456789012345678901234567890' ;
693 eval ($my_stmt) ;
694 eval prepare stmt1 from "$my_stmt" ;
695 execute stmt1 ;
696 execute stmt1 ;
699 ## many parameters ( 50 )
700 --disable_query_log
701 set @arg00= 1;
702 set @arg01= 1; 
703 set @arg02= 1;
704 set @arg03= 1; 
705 set @arg04= 1;
706 set @arg05= 1; 
707 set @arg06= 1;
708 set @arg07= 1;
709 set @arg10= 1;
710 set @arg11= 1; 
711 set @arg12= 1;
712 set @arg13= 1; 
713 set @arg14= 1;
714 set @arg15= 1; 
715 set @arg16= 1;
716 set @arg17= 1; 
717 set @arg20= 1;
718 set @arg21= 1; 
719 set @arg22= 1;
720 set @arg23= 1; 
721 set @arg24= 1;
722 set @arg25= 1; 
723 set @arg26= 1;
724 set @arg27= 1; 
725 set @arg30= 1;
726 set @arg31= 1; 
727 set @arg32= 1;
728 set @arg33= 1; 
729 set @arg34= 1;
730 set @arg35= 1; 
731 set @arg36= 1;
732 set @arg37= 1; 
733 set @arg40= 1;
734 set @arg41= 1; 
735 set @arg42= 1;
736 set @arg43= 1; 
737 set @arg44= 1;
738 set @arg45= 1; 
739 set @arg46= 1;
740 set @arg47= 1; 
741 set @arg50= 1;
742 set @arg51= 1; 
743 set @arg52= 1;
744 set @arg53= 1; 
745 set @arg54= 1;
746 set @arg55= 1; 
747 set @arg56= 1;
748 set @arg57= 1; 
749 set @arg60= 1;
750 set @arg61= 1;
751 --enable_query_log
753 select 'ABC' as my_const_col FROM t1 WHERE
754 @arg00=@arg00 and @arg00=@arg00 and @arg00=@arg00 and @arg00=@arg00 and
755 @arg00=@arg00 and @arg00=@arg00 and @arg00=@arg00 and @arg00=@arg00 and
756 @arg00=@arg00 and @arg00=@arg00 and @arg00=@arg00 and @arg00=@arg00 and
757 @arg00=@arg00 and @arg00=@arg00 and @arg00=@arg00 and @arg00=@arg00 and
758 @arg00=@arg00 and @arg00=@arg00 and @arg00=@arg00 and @arg00=@arg00 and
759 @arg00=@arg00 and @arg00=@arg00 and @arg00=@arg00 and @arg00=@arg00 and
760 @arg00=@arg00 ;
761 prepare stmt1 from ' select ''ABC'' as my_const_col FROM t1 WHERE
762  ? = ?  and  ? = ?  and  ? = ?  and  ? = ?  and
763  ? = ?  and  ? = ?  and  ? = ?  and  ? = ?  and
764  ? = ?  and  ? = ?  and  ? = ?  and  ? = ?  and
765  ? = ?  and  ? = ?  and  ? = ?  and  ? = ?  and
766  ? = ?  and  ? = ?  and  ? = ?  and  ? = ?  and
767  ? = ?  and  ? = ?  and  ? = ?  and  ? = ?  and
768  ? = ?  ' ;
769 execute stmt1 using 
770 @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, 
771 @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00,
772 @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, 
773 @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, 
774 @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, 
775 @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, 
776 @arg00, @arg00;
777 execute stmt1 using 
778 @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, 
779 @arg10, @arg11, @arg12, @arg13, @arg14, @arg15, @arg16, @arg17,
780 @arg20, @arg21, @arg22, @arg23, @arg24, @arg25, @arg26, @arg27, 
781 @arg30, @arg31, @arg32, @arg33, @arg34, @arg35, @arg36, @arg37, 
782 @arg40, @arg41, @arg42, @arg43, @arg44, @arg45, @arg46, @arg47, 
783 @arg50, @arg51, @arg52, @arg53, @arg54, @arg55, @arg56, @arg57, 
784 @arg60, @arg61 ;
786 # cases derived from client_test.c: test_mem_overun()
787 --disable_warnings
788 drop table if exists t5 ;
789 --enable_warnings
791 set @col_num= 1000 ;
793 --disable_query_log
794 set @string= 'create table t5( ' ;
795 let $1=`select @col_num - 1` ;
796 while ($1)
798   eval set @string= concat(@string, 'c$1 int,') ;
799   dec $1 ;
801 set @string= concat(@string, 'c0 int)' );
802 --enable_query_log
803 select @string as "" ;
804 prepare stmt1 from @string ;
805 execute stmt1 ;
807 --disable_query_log
808 set @string= 'insert into t5 values(' ;
809 let $1=`select @col_num - 1` ;
810 while ($1)
812   eval set @string= concat(@string, '1 ,') ;
813   dec $1 ;
815 eval set @string= concat(@string, '1 )') ;
816 --enable_query_log
817 select @string as "" ;
818 prepare stmt1 from @string ;
819 execute stmt1 ;
821 prepare stmt1 from ' select * from t5 ' ;
822 --enable_metadata
823 # prevent too long lines
824 --vertical_results
825 --disable_result_log
826 execute stmt1 ;
827 --enable_result_log
828 --disable_metadata
829 --horizontal_results
831 drop table t1, t5, t9;
833 ##### RULES OF THUMB TO PRESERVE THE SYSTEMATICS OF THE PS TEST CASES #####
835 # 0. You  don't have the time to 
836 #    - read and pay attention to these rules of thumb
837 #    - accept that QA may move your test case to a different place
838 #      (I will not change your code!!) .
839 #    Please append your test case to
840 #        t/ps.test
842 # 1. You have more time and want to get as much value from you test case as
843 #    possible. Please try to make the following decisions:
845 #    Will the execution or result of the sub test case depend on the
846 #    properties of a storage engine ?
848 #      NO   --> alter t/ps_1general.test (Example: Command with syntax error)
849 #               If you need a table, please try to use
850 #               t1               - very simple table
851 #               t9 - table with nearly all available column types
852 #               whenever possible.
854 #               The structure and the content of these tables can be found in
855 #               include/ps_create.inc  CREATE TABLE ...
856 #               include/ps_renew.inc   DELETE all rows and INSERT some rows
858 #               Both tables are managed by the same storage engine.
859 #               The type of the storage engine is stored in the variable 
860 #               '$type' .  In ps_1general.test $type is set to 'MYISAM'.
861 #    
862 #               Please feel free to source ps_create.inc or ps_renew.inc
863 #               whenever you think it helps. But please restore the original
864 #               state of these tables after your tests, because the following
865 #               statements may depend on it.
867 #      YES
868 #       |
869 #       |
870 #    Is it possible to apply the sub test case to all table types ?
871 #      YES  --> alter include/ps_query.inc   (for SELECTs)
872 #                     include/ps_modify.inc  (for INSERT/UPDATE/DELETE)
873 #                     include/ps_modify1.inc (also for INSERT/UPDATE/DELETE,
874 #                                but t/ps_5merge.test will not source that file)
875 #               Please try to find an appropriate place within the file.
876 #               It would be nice if we have some systematics in the
877 #               order of the sub test cases (if possible).
879 #               Please be aware, that
880 #                  include: ps_query.inc, ps_modify.inc, ps_modify1.inc
881 #               will be sourced by several test case files stored within the 
882 #               subdirectory 't'. So every change here will affect several test
883 #               cases.
885 #      NO
886 #       |
887 #       |
888 #    Append the sub test case to the appropriate 
889 #                  ps_<number><table type>.test  .
891 # 2. The current structure of the PS tests
893 #    t/ps_1general.test     Check of basic PS features, SHOW commands and DDL
894 #                           The tests should not depend on the table type.
896 #    t/ps_2myisam           Check of PS on tables of type MYISAM .
897 #    t/ps_3innodb           Check of PS on tables of type InnoDB .
898 #    ...
899 #    t/ps_6bdb              Check of PS on tables of type BDB .
900 #         All storage engine related tests use the variable $type to hold the
901 #         name of the storage engine.        
903 #    include/ps_query.inc   test cases with SELECT/... 
904 #                           These test cases should not modify the content or
905 #                           the structure (DROP/ALTER..) of the tables
906 #                           't1' and 't9'.
907 #    include/ps_modify.inc  test cases with INSERT/UPDATE/... 
908 #                           These test cases should not modify the structure 
909 #                           (DROP/ALTER..) of the tables
910 #                           't1' and 't9'.
911 #         These two test sequences will be applied to all table types .
913 #    include/ps_modify1.inc test cases with INSERT/UPDATE/...
914 #         This test sequences will be applied to all table types 
915 #         except MERGE tables.
917 #    include/ps_create.inc  DROP and CREATE of the tables 
918 #                             't1' and 't9' .
919 #    include/ps_renew.inc   DELETE all rows and INSERT some rows, that means
920 #                           recreate the original content of these tables.
921 #         Please do not alter the commands concerning these two tables.
923 #  Please feel free and encouraged to exploit the current code sharing
924 #  mechanism of the 'ps_<number><table type>' test cases. It is an convenient
925 #  way to check all storage engines.
927 #  Thank you for reading these rules of thumb.
929 #     Matthias
931 # End of 4.1 tests