1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
|
###################################################
# #
# Functions within VIEWs #
# #
###################################################
# 2007-11-09 HHunger enabled all disabled parts belonging to fixed bugs.
# 2006-12-08 mleich Maintenance + refinements
# 2005-09-14 mleich Create this test
#
# 0. Some notes about this test:
# #################################################################
#
# 0.1 This test is unfinished and incomplete, but already useful.
# -----------------------------------------------------------------
# 0.1.1 There will be architectural changes in future.
# The long sequences with
# let $col_type= <column to use>;
# --source suite/funcs_1/views/<file containing the
# select with function>
# per every column type do not look very smart.
#
# Ugly combinations of functions and data types must be also checked,
# because an accidental typo like assigning a string column to an
# numeric parameter could happen and should not result in a server crash.
#
# Maybe it is better to change the architecture of this test in such
# a way:
# 1. A generator script (this one or written in Perl or SP language)
# generates an prototype of the the final testscript.
# 2. Some manual adjustments because of open bugs (depending on
# storage engine or function) might be needed (I hope not :)
# 3. The final testscript is pushed to the other regression testscripts.
# Advantage: The analysis of bugs, extension and maintenance of this
# test will be much easier.
# Disadvantage: Much redundant code within the final testscript,
# but the maintenance of the redundant code will be done
# by the script generator.
#
# 0.1.2 The behaviour of SELECTs on VIEWs could be affected by the SQL mode
# which was valid during VIEW creation time. This means some variations
# of the SQL mode are needed.
# 0.1.3 There are much more functions to be tested.
# 0.1.4 The result sets of some CAST sub testcases with ugly function parameter
# column data type combinations must be discussed.
#
#
# 0.2 How to valuate the test results:
# ---------------------------------------------------------------------------
# Due to the extreme "greedy bug hunting" architecture (combinatorics
# + heavy use of sourced scripts) of the following tests, there will be
# - no abort of the test execution, when one statements gets an return
# code != 0 (The sub testcases are independend.)
# But statements, which do not make sense like SELECT on non existent
# VIEW will be omitted. This decreases the amount of useless output.
# - a file with expected results, which might contain incorrect server
# responses
# There are open bugs and I cannot omit statements which reveal these
# bugs.
# But there will be a special messages within the protocol files.
# Example:
# "Attention: CAST --> SIGNED INTEGER
# The file with expected results suffers from Bug 5913";
# means, the file with expected results contains result sets which
# are known to be wrong.
# "Attention: The last <whatever> failed"
# means, a statement which should be successful (bugfree MySQL)
# failed.
#
# "Passed" : The behaviour of your MySQL version does not differ from the
# version used to generate the files with expected results.
# Known bugs affecting these tests could be retrieved by
# grep "Attention" r/<testcase>.result .
#
# "Failed" : The behaviour of your MySQL version differs from the version
# used to generate the files with expected results.
# These differences could be result of bug fixes or new bugs.
# Please compare r/<testcase>.reject and r/<testcase>.result .
#
# The test will abort if one of the basic preparation statement fails
# (except ALTER TABLE ADD ...).
#
#
# 0.3 How to debug sub testcases with "unexpected" results:
# ---------------------------------------------------------------------------
# 1. Please execute this test and copy the "reject" file to a save place.
# Search within the "reject" file for the sub testcase (the SELECT)
# with the suspicious result set or server response.
# Now all t1_values records are preloaded.
# 2. Start the server without the initial cleanup of databases etc.
# This preserves the content of the table t1_values, which
# might be needed for replaying the situation.
# Example:
# ./mysql-test-run.pl --socket=var/tmp/master.sock --start-dirty
# 3. Issue the statements needed by using "mysql" or "mysqltest".
#
# Maybe an internal routine of this test fails. Please ask me (mleich) or
# enable the logging of auxiliary queries and try to analyze the
# problem.
#
#
# 0.4 How to extend the number of functions to be checked:
# ---------------------------------------------------------------------------
# Please jump to the paragraphs of the basic preparations
# 1. Extend t1_values with the columns you need
# 2. Insert some predefinded rows
# 3. Add the SELECTs with function which should be used within VIEWs
# and
# records which should be used dedicated to the SELECT above
#
#
# 0.5 How to alter the internal routines of this test:
# ---------------------------------------------------------------------------
# Please try to achieve a state where the protocol
# - contains ALL statements, which are needed to replay a problem within
# the field of functions within VIEWs
# - does not contain too much auxiliary statements, which are not needed
# to replay a problem (--> "--disable_query_log")
# Example:
# Needed for replay:
# - DROP/CREATE TABLE t1_values
# - INSERT of records into t1_values
# - DROP/CREATE/SELECT/SHOW VIEW v1
# - SELECT direct on base table
# Not needed for replay:
# - SET @<uservariable> = <value>
# - DROP/CREATE/INSERT/SELECT TABLE t1_selects, t1_modes
#
#
# 0.6 A trick for checking results
# ---------------------------------------------------------------------------
# Standard setting for common execution of this test:
let $simple_select_result= 1;
let $view_select_result= 1;
# The implementation of some additional function tests may lead to
# masses of result sets, which have to be checked. The result sets of
# the simple selects on the base table must equal the result sets of the
# queries on the VIEWs. This step could be made more comfortable by
# 1. Edit this file to
# let $simple_select_result= 1;
# let $view_select_result= 0;
# Please execute this test.
# The script will omit CREATE/DROP/SHOW/SELECT on VIEW.
# The "reject" file contains only the simple select result sets.
# 2. Edit this file to
# let $simple_select_result= 0;
# let $view_select_result= 1;
# Please execute this test.
# The script will work with the VIEWs, but omit the simple selects.
# The "reject" file contains the view select result sets.
# 3. Compare the "reject" files of 1. and 2. within a graphical diff tool.
#
#
SET timestamp=unix_timestamp('2001-02-03 10:20:30');
--disable_warnings
DROP TABLE IF EXISTS t1_selects, t1_modes, t1_values;
DROP VIEW IF EXISTS v1;
--enable_warnings
--disable_query_log
# Storage for the SELECTs to be used for the VIEW definition
# Attention: my_select must be no too small because a statement like
# SELECT LOAD_FILE(< file in MYSQLTEST_VARDIR >)
# AS my_col,
# id FROM t1_values';
# might be a very long
# Bug#38427 "Data too long" ... tests "<ENGINE>_func_view" fail
CREATE TABLE t1_selects
(
id BIGINT AUTO_INCREMENT,
my_select VARCHAR(1000) NOT NULL,
disable_result ENUM('Yes','No') NOT NULL default 'No',
PRIMARY KEY(id),
UNIQUE (my_select)
) ENGINE=MyISAM;
# MODES to be checked
CREATE TABLE t1_modes
(
id BIGINT AUTO_INCREMENT,
my_mode VARCHAR(200) NOT NULL,
PRIMARY KEY(id),
UNIQUE (my_mode)
) ENGINE=MyISAM;
--enable_query_log
# The table to be used in the FROM parts of the SELECTs
--replace_result $type <engine_to_be_tested>
eval CREATE TABLE t1_values
(
id BIGINT AUTO_INCREMENT,
select_id BIGINT,
PRIMARY KEY(id)
) ENGINE = $type;
##### BEGIN Basic preparations #######################################
#
# 1. Extend t1_values with the columns you need
# - the column name must show the data type
# - do not add NOT NULL columns
# - do not worry if the intended column data type is not
# available for some storage engines
# Please do not forget to assign values for the new columns (paragraph 2.).
--disable_abort_on_error
ALTER TABLE t1_values ADD my_char_30 CHAR(30);
ALTER TABLE t1_values ADD my_varchar_1000 VARCHAR(1000);
ALTER TABLE t1_values ADD my_binary_30 BINARY(30);
ALTER TABLE t1_values ADD my_varbinary_1000 VARBINARY(1000);
ALTER TABLE t1_values ADD my_datetime DATETIME;
ALTER TABLE t1_values ADD my_date DATE;
ALTER TABLE t1_values ADD ts_dummy TIMESTAMP;
ALTER TABLE t1_values ADD my_timestamp TIMESTAMP;
ALTER TABLE t1_values ADD my_time TIME;
ALTER TABLE t1_values ADD my_year YEAR;
ALTER TABLE t1_values ADD my_bigint BIGINT;
ALTER TABLE t1_values ADD my_double DOUBLE;
ALTER TABLE t1_values ADD my_decimal DECIMAL(64,30);
--enable_abort_on_error
#-------------------------------------------------------------------------------
#
# 2. Insert some predefinded rows
# Predefined rows
# - t1_values.select_id IS NULL
# - will be selected by every SELECT with function to be tested
# - have to be inserted when sql_mode = 'traditional' is valid, because
# we do not want to start with "illegal/unexpected/..." values.
# Such experiments should be done in other testcases.
# Please be careful
# - modifying column values of predefined rows they might change many
# result sets
# - additional predefined rows should be really useful for the majority of
# all sub testcases, since they blow up all result sets.
SET sql_mode = 'traditional';
#
# 2.1 record -- everything to NULL
INSERT INTO t1_values SET id = 0;
#
# 2.2 record -- everything to "minimum"
# numbers, date/time types -> minimum of range
# strings, blobs, binaries -> ''
# FIXME enum, set ??
INSERT INTO t1_values SET
my_char_30 = '',
my_varchar_1000 = '',
my_binary_30 = '',
my_varbinary_1000 = '',
my_datetime = '0001-01-01 00:00:00',
my_date = '0001-01-01',
my_timestamp = '1970-01-01 14:00:01',
my_time = '-838:59:59',
my_year = '1901',
my_bigint = -9223372036854775808,
my_decimal = -9999999999999999999999999999999999.999999999999999999999999999999 ,
my_double = -1.7976931348623E+308;
# shortened due to bug#32285
# my_double = -1.7976931348623157E+308;
#
# 2.3 record -- everything to "maximum"
# numbers, date/time types -> maximum of range
# strings, blobs, binaries -> '<- full length of used data type>'
# FIXME enum, set ??
INSERT INTO t1_values SET
my_char_30 = '<--------30 characters------->',
my_varchar_1000 = CONCAT('<---------1000 characters',
RPAD('',965,'-'),'--------->'),
my_binary_30 = '<--------30 characters------->',
my_varbinary_1000 = CONCAT('<---------1000 characters',
RPAD('',965,'-'),'--------->'),
my_datetime = '9999-12-31 23:59:59',
my_date = '9999-12-31',
my_timestamp = '2038-01-01 02:59:59',
my_time = '838:59:59',
my_year = 2155,
my_bigint = 9223372036854775807,
my_decimal = +9999999999999999999999999999999999.999999999999999999999999999999 ,
my_double = 1.7976931348623E+308;
# shortened due to bug#32285
# my_double = -1.7976931348623157E+308;
#
# 2.4 record -- everything to "magic" value if available or
# other interesting value
# numbers -> 0
# strings, blobs, binaries -> not full length of used data type, "exotic"
# characters and preceding and trailing spaces
# FIXME enum, set ??
INSERT INTO t1_values SET
my_char_30 = ' ---äÖüß@µ*$-- ',
my_varchar_1000 = ' ---äÖüß@µ*$-- ',
my_binary_30 = ' ---äÖüß@µ*$-- ',
my_varbinary_1000 = ' ---äÖüß@µ*$-- ',
my_datetime = '2004-02-29 23:59:59',
my_date = '2004-02-29',
my_timestamp = '2004-02-29 23:59:59',
my_time = '13:00:00',
my_year = 2000,
my_bigint = 0,
my_decimal = 0.0,
my_double = 0;
#
# 2.5 record -- everything to "harmless" value if available
# numbers -> -1 (logical)
# strings, blobs, binaries -> '-1' useful for numeric functions
# FIXME enum, set ??
INSERT INTO t1_values SET
my_char_30 = '-1',
my_varchar_1000 = '-1',
my_binary_30 = '-1',
my_varbinary_1000 = '-1',
my_datetime = '2005-06-28 10:00:00',
my_date = '2005-06-28',
my_timestamp = '2005-06-28 10:00:00',
my_time = '10:00:00',
my_year = 2005,
my_bigint = -1,
my_decimal = -1.000000000000000000000000000000,
my_double = -0.1E+1;
#-------------------------------------------------------------------------------
#
# 3. Add the SELECTs with function which should be used within VIEWs
# and
# records which should be used dedicated to the SELECT above
# - Please avoid WHERE clauses
# - Include the PRIMARY KEY ("id") of the base table t1_values into the
# select column list
# - Include the base table column used as function parameter into the
# select column list, because it is much easier to check the results
# - Do not forget to escape single quotes
# Example:
# SET @my_select = 'SELECT sqrt(my_bigint), my_bigint, id FROM t1_values'
# SET @my_select = 'SELECT CONCAT(\'A\',my_char_30), id FROM t1_values';
# - Statements, which reveal open crashing bugs MUST be disabled.
# - Result sets must not contain data, which might differ between boxes
# executing this test.
# Example: current time, absolute path to some files ...
# - Please derive the functions to be checked from the MySQL manual
# and use the same order. This means copy the the function names as
# comment into this test and start to implement a testcase for your
# most preferred function.
# This method avoids that we forget a function and gives a better
# overview.
#
# If you have the time to check the result sets do the insert of the
# SELECT with function via:
# eval SET @my_select =
# '<your SELECT>';
# --source suite/funcs_1/views/fv1.inc
# fv1.inc sets t1_selects.disable_result to 'No' and the effect will be,
# that the result set will be logged.
#
# If you do not have the time to check the result sets do the insert of the
# SELECT with function via:
# eval SET @my_select =
# '<your SELECT>';
# --source suite/funcs_1/views/fv2.inc
# fv2.inc sets t1_selects.disable_result to 'Yes' and the effect will be,
# that the result set will be not logged.
# This should be only a temporary solution and it does not remove the
# need to check the server return codes.
# That means even when we do not have the time to check the correctness of
# the result sets, we check if
# - SELECT <function> or
# - SELECT * FROM <VIEW with function>
# crash the server or get suspicious server responses.
#
# - the SELECTs will be applied to the rows defined here (3.) +
# all predefined rows (2.)
# - the rows dedicated to the SELECT should contain especially interesting
# column values or combinations of column values, which are not covered
# by the predefined records
# - The records have to be inserted when sql_mode = 'traditional' is valid.
# - Please do not insert records with column values where the allowed
# range is exceeded. The SQL mode 'traditional' will prevent such
# inserts. Such experiments should be done in other tests, because
# they inflate the current test without giving an appropriate value.
#
# Example:
# The function to be tested is "sqrt".
# The minimum, maximum, default and NULL value are covered by the
# predefined rows.
# A value where sqrt(<value>) = <integer value> in strict mathematics
# would be of interest.
# --> Add a record with my_bigint = 4
# --> Just for fun my_bigint = -25 .
#
# Some internal stuff
PREPARE ins_sel_with_result FROM "INSERT INTO t1_selects SET my_select = @my_select,
disable_result = 'No'" ;
PREPARE ins_sel_no_result FROM "INSERT INTO t1_selects SET my_select = @my_select,
disable_result = 'Yes'" ;
SET sql_mode = 'traditional';
# --disable_query_log
let $col_type= my_bigint;
# Example:
# eval SET @my_select = 'SELECT CONCAT(''A'', $col_type), $col_type, id';
eval SET @my_select = 'SELECT sqrt($col_type), $col_type, id FROM t1_values';
--source suite/funcs_1/views/fv1.inc
# Content of suite/funcs_1/views/fv1.inc :
# --disable_query_log
# EXECUTE ins_sel_with_result;
# SET @select_id = LAST_INSERT_ID();
# --enable_query_log
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = 4;
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = -25;
# SELECT * FROM t1_values;
# 1. Cast Functions and Operators
# 1.1 CAST
#
# Note(mleich): I guess the CAST routines are used in many other functions.
# Therefore check also nearly all "ugly" variants like
# CAST(<string composed of non digits> AS DECIMAL) here.
#
# suite/funcs_1/views/fv_cast.inc contains
# SELECT CAST($col_type AS $target_type), ...
#
#
# 1.1.1. CAST --> BINARY
--echo ##### 1.1.1. CAST --> BINARY
let $target_type= BINARY;
#
let $col_type= my_char_30;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_varchar_1000;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_binary_30;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_varbinary_1000;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_bigint;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_decimal;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_double;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_datetime;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_date;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_timestamp;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_time;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_year;
--source suite/funcs_1/views/fv_cast.inc
# 1.1.2. CAST --> CHAR
--echo ##### 1.1.2. CAST --> CHAR
let $target_type= CHAR;
#
let $col_type= my_char_30;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_varchar_1000;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_binary_30;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_varbinary_1000;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_bigint;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_decimal;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_double;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_datetime;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_date;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_timestamp;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_time;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_year;
--source suite/funcs_1/views/fv_cast.inc
# 1.1.3. CAST --> DATE
--echo ##### 1.1.3. CAST --> DATE
let $target_type= DATE;
#
let $col_type= my_char_30;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = '2005-06-27';
let $col_type= my_varchar_1000;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = '2005-06-27';
let $col_type= my_binary_30;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = '2005-06-27';
let $col_type= my_varbinary_1000;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = '2005-06-27';
let $col_type= my_bigint;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = 20050627;
let $col_type= my_double;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = +20.050627E+6;
let $col_type= my_datetime;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_date;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_timestamp;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_time;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_year;
--source suite/funcs_1/views/fv_cast.inc
# 1.1.4. CAST --> DATETIME
--echo ##### 1.1.4. CAST --> DATETIME
let $target_type= DATETIME;
#
let $col_type= my_char_30;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = '2005-06-27 17:58';
let $col_type= my_varchar_1000;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = '2005-06-27 17:58';
let $col_type= my_binary_30;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = '2005-06-27 17:58';
let $col_type= my_varbinary_1000;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = '2005-06-27 17:58';
let $col_type= my_bigint;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = 200506271758;
let $col_type= my_double;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = +0.0200506271758E+13;
let $col_type= my_datetime;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_date;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_timestamp;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_time;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_year;
--source suite/funcs_1/views/fv_cast.inc
# 1.1.5. CAST --> TIME
--echo ##### 1.1.5. CAST --> TIME
let $target_type= TIME;
#
let $col_type= my_char_30;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = '1 17:58';
let $col_type= my_varchar_1000;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = '1 17:58';
let $col_type= my_binary_30;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = '1 17:58';
let $col_type= my_varbinary_1000;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = '1 17:58';
let $col_type= my_bigint;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = 1758;
let $col_type= my_double;
# Bug#12440: CAST(data type DOUBLE AS TIME) strange results;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = +1.758E+3;
let $col_type= my_datetime;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_date;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_timestamp;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_time;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_year;
--source suite/funcs_1/views/fv_cast.inc
# 1.1.6. CAST --> DECIMAL
--echo ##### 1.1.6. CAST --> DECIMAL
# Set the following to (37,2) since the default was changed to (10,0) - OBN
let $target_type= DECIMAL(37,2);
#
let $col_type= my_char_30;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = '-3333.3333';
let $col_type= my_varchar_1000;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = '-3333.3333';
let $col_type= my_binary_30;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = '-3333.3333';
let $col_type= my_varbinary_1000;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = '-3333.3333';
let $col_type= my_bigint;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_decimal;
--source suite/funcs_1/views/fv_cast.inc
# Bug#13349: CAST(1.0E+300 TO DECIMAL) returns wrong result + diff little/big endian;
let $col_type= my_double;
--source suite/funcs_1/views/fv_cast.inc
eval INSERT INTO t1_values SET select_id = @select_id,
$col_type = -0.33333333E+4;
let $col_type= my_datetime;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_date;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_timestamp;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_time;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_year;
--source suite/funcs_1/views/fv_cast.inc
# 1.1.7. CAST --> SIGNED INTEGER
--echo ##### 1.1.7. CAST --> SIGNED INTEGER
let $target_type= SIGNED INTEGER;
#
let $message=
"Attention: CAST --> SIGNED INTEGER
Bug#5913 Traditional mode: BIGINT range not correctly delimited
Status: To be fixed later";
--source include/show_msg80.inc
let $col_type= my_char_30;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_varchar_1000;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_binary_30;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_varbinary_1000;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_bigint;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_decimal;
--source suite/funcs_1/views/fv_cast.inc
# Bug #13344: CAST(1E+300 TO signed int) on little endian CPU, wrong result;
let $col_type= my_double;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_datetime;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_date;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_timestamp;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_time;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_year;
--source suite/funcs_1/views/fv_cast.inc
# 1.1.8. CAST --> UNSIGNED INTEGER
--echo ##### 1.1.8. CAST --> UNSIGNED INTEGER
let $target_type= UNSIGNED INTEGER;
#
let $message=
"Attention: CAST --> UNSIGNED INTEGER
The file with expected results suffers from Bug 5913";
--source include/show_msg80.inc
let $col_type= my_char_30;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_varchar_1000;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_binary_30;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_varbinary_1000;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_bigint;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_decimal;
--source suite/funcs_1/views/fv_cast.inc
let $message= some statements disabled because of
Bug#5913 Traditional mode: BIGINT range not correctly delimited;
--source include/show_msg80.inc
# Bug#8663 cant use bgint unsigned as input to cast
let $col_type= my_double;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_datetime;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_date;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_timestamp;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_time;
--source suite/funcs_1/views/fv_cast.inc
let $col_type= my_year;
--source suite/funcs_1/views/fv_cast.inc
# 1.2. BINARY
# Manual: BINARY str is a shorthand for CAST(str AS BINARY).
# Therefore we do not test it here in the moment.
# FIXME: Add testcases for str in CHAR and VARCHAR only.
# 1.3 CONVERT(expr USING transcoding_name)
#
# 1.3.1 CONVERT(expr USING utf8)
let $target_charset= utf8;
#
let $col_type= my_char_30;
eval SET @my_select = 'SELECT CONVERT($col_type USING $target_charset),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv1.inc
let $col_type= my_varchar_1000;
eval SET @my_select = 'SELECT CONVERT($col_type USING $target_charset),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv1.inc
let $col_type= my_binary_30;
eval SET @my_select = 'SELECT CONVERT($col_type USING $target_charset),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv1.inc
let $col_type= my_varbinary_1000;
eval SET @my_select = 'SELECT CONVERT($col_type USING $target_charset),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv1.inc
#
# 1.3.2 CONVERT(expr USING koi8r)
let $target_charset= koi8r;
let $col_type= my_char_30;
eval SET @my_select = 'SELECT CONVERT($col_type USING $target_charset),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv1.inc
let $col_type= my_varchar_1000;
eval SET @my_select = 'SELECT CONVERT($col_type USING $target_charset),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv1.inc
let $col_type= my_binary_30;
eval SET @my_select = 'SELECT CONVERT($col_type USING $target_charset),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv1.inc
let $col_type= my_varbinary_1000;
eval SET @my_select = 'SELECT CONVERT($col_type USING $target_charset),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv1.inc
# 2. Control Flow Functions
# 2.1. CASE value WHEN [compare-value] THEN result [WHEN ...] [ELSE result]
# END or
# CASE WHEN [condition] THEN result [WHEN ...] [ELSE result] END
#
# FIXME: to be implemented
#
# 2.2. IF(expr1,expr2,expr3)
# expr1 is TRUE when (expr1 <> 0 and expr1 <> NULL) is fulfilled
#
# 2.2.1 IF(expr1,expr2,expr3) with expr1 = <column>
#
# Note(mleich): Strings, which do not contain a number -> FALSE
#
# suite/funcs_1/views/fv_if1.inc contains
# SELECT IF($col_type, 'IS TRUE', 'IS NOT TRUE'), ...
#
let $col_type= my_char_30;
--source suite/funcs_1/views/fv_if1.inc
#
let $col_type= my_varchar_1000;
--source suite/funcs_1/views/fv_if1.inc
#
let $col_type= my_binary_30;
--source suite/funcs_1/views/fv_if1.inc
#
let $col_type= my_varbinary_1000;
--source suite/funcs_1/views/fv_if1.inc
#
let $col_type= my_bigint;
--source suite/funcs_1/views/fv_if1.inc
#
let $col_type= my_decimal;
--source suite/funcs_1/views/fv_if1.inc
#
let $col_type= my_double;
--source suite/funcs_1/views/fv_if1.inc
#
let $col_type= my_datetime;
--source suite/funcs_1/views/fv_if1.inc
#
let $col_type= my_date;
--source suite/funcs_1/views/fv_if1.inc
#
let $col_type= my_timestamp;
--source suite/funcs_1/views/fv_if1.inc
#
let $col_type= my_time;
--source suite/funcs_1/views/fv_if1.inc
#
let $col_type= my_year;
--source suite/funcs_1/views/fv_if1.inc
# 2.2.2 IF(expr1,expr2,expr3) with expr1 != <column>
#
# suite/funcs_1/views/fv_if2.inc contains
# SELECT IF($col_type IS NULL, 'IS NULL', 'IS NOT NULL'), ...
#
# Note(mleich): July 2005
# IF($col_type IS NULL, ...) is mapped to a VIEW definition
# create ... view ... as
# select if(isnull(`test`.`t1`.`f1`),_latin1'IS NULL',
# _latin1'IS NOT NULL'),...
#
# Bug#11689 success on Create view .. IF(col1 IS NULL,...), col2 ; but SELECT fails
let $col_type= my_char_30;
--source suite/funcs_1/views/fv_if2.inc
#
let $col_type= my_varchar_1000;
--source suite/funcs_1/views/fv_if2.inc
#
let $col_type= my_binary_30;
--source suite/funcs_1/views/fv_if2.inc
#
let $col_type= my_varbinary_1000;
--source suite/funcs_1/views/fv_if2.inc
#
let $col_type= my_bigint;
--source suite/funcs_1/views/fv_if2.inc
#
let $col_type= my_decimal;
--source suite/funcs_1/views/fv_if2.inc
#
let $col_type= my_double;
--source suite/funcs_1/views/fv_if2.inc
#
let $col_type= my_datetime;
--source suite/funcs_1/views/fv_if2.inc
#
let $col_type= my_date;
--source suite/funcs_1/views/fv_if2.inc
#
let $col_type= my_timestamp;
--source suite/funcs_1/views/fv_if2.inc
#
let $col_type= my_time;
--source suite/funcs_1/views/fv_if2.inc
#
let $col_type= my_year;
--source suite/funcs_1/views/fv_if2.inc
# 2.3. IFNULL(expr1,expr2)
# If expr1 is not NULL, IFNULL() returns expr1, else it returns expr2.
#
# suite/funcs_1/views/fv_ifnull.inc contains
# SELECT IFNULL($col_type, 'IS_NULL'), ....
# FIXME: The mixup of non string column values
# and the string 'IS NULL' within the first column of the
# result table is extreme ugly.
# CAST(IFNULL($col_type, 'IS_NULL') AS CHAR) looks better, but
# it has the disadvantage, that it involves CAST as additional
# function.
#
let $col_type= my_char_30;
--source suite/funcs_1/views/fv_ifnull.inc
#
let $col_type= my_varchar_1000;
--source suite/funcs_1/views/fv_ifnull.inc
#
let $col_type= my_binary_30;
--source suite/funcs_1/views/fv_ifnull.inc
#
let $col_type= my_varbinary_1000;
--source suite/funcs_1/views/fv_ifnull.inc
#
let $col_type= my_bigint;
--source suite/funcs_1/views/fv_ifnull.inc
#
let $col_type= my_decimal;
--source suite/funcs_1/views/fv_ifnull.inc
#
let $col_type= my_double;
--source suite/funcs_1/views/fv_ifnull.inc
#
let $col_type= my_datetime;
--source suite/funcs_1/views/fv_ifnull.inc
#
let $col_type= my_date;
--source suite/funcs_1/views/fv_ifnull.inc
#
let $col_type= my_timestamp;
--source suite/funcs_1/views/fv_ifnull.inc
#
let $col_type= my_time;
--source suite/funcs_1/views/fv_ifnull.inc
#
let $col_type= my_year;
--source suite/funcs_1/views/fv_ifnull.inc
# 2.4. NULLIF(expr1,expr2)
# Returns NULL if expr1 = expr2 is true, else returns expr1.
# This is the same as
# CASE WHEN expr1 = expr2 THEN NULL ELSE expr1 END.
#
# FIXME: to be implemented
#
# 3. String Functions
# 3.1. ASCII(str)
# 3.2. BIN(N)
# FIXME: to be implemented
#
# 3.3. BIT_LENGTH(str)
# Returns the length of the string str in bits.
#
let $col_type= my_char_30;
eval SET @my_select = 'SELECT BIT_LENGTH($col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv1.inc
let $col_type= my_varchar_1000;
eval SET @my_select = 'SELECT BIT_LENGTH($col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv1.inc
let $col_type= my_binary_30;
eval SET @my_select = 'SELECT BIT_LENGTH($col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv1.inc
let $col_type= my_varbinary_1000;
eval SET @my_select = 'SELECT BIT_LENGTH($col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv1.inc
# 3.4. CHAR(N,...)
# 3.5. CHAR_LENGTH(str)
# 3.6 CHARACTER_LENGTH(str)
# CHARACTER_LENGTH() is a synonym for CHAR_LENGTH().
# 3.7. COMPRESS(string_to_compress)
# 3.8. CONCAT(str1,str2,...)
# 3.9. CONCAT_WS(separator,str1,str2,...)
# 3.10. CONV(N,from_base,to_base)
# 3.11. ELT(N,str1,str2,str3,...)
# 3.12. EXPORT_SET(bits,on,off[,separator[,number_of_bits]])
# 3.13. FIELD(str,str1,str2,str3,...)
# 3.14. FIND_IN_SET(str,strlist)
# 3.15. HEX(N_or_S
# 3.16. INSERT(str,pos,len,newstr)
# 3.17. INSTR(str,substr)
# This is the same as the two-argument form of LOCATE(),
# except that the arguments are swapped.
# The majority of the testcases should be made with LOCATE().
# Therefore test only one example here.
let $col_type= my_char_30;
eval SET @my_select = 'SELECT INSTR($col_type, ''char''),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
# 3.18. LCASE(str)
# LCASE() is a synonym for LOWER().
# The majority of the testcases should be made with LOWER().
# Therefore test only one example here.
let $col_type= my_varchar_1000;
eval SET @my_select = 'SELECT LCASE($col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
# 3.19. LEFT(str,len)
# Returns the leftmost len characters from the string str.
let $col_type= my_char_30;
eval SET @my_select =
'SELECT LEFT($col_type, 2), $col_type, id FROM t1_values';
--source suite/funcs_1/views/fv1.inc
let $col_type= my_varchar_1000;
eval SET @my_select =
'SELECT LEFT($col_type, 2), $col_type, id FROM t1_values';
--source suite/funcs_1/views/fv1.inc
let $col_type= my_binary_30;
eval SET @my_select =
'SELECT LEFT($col_type, 2), $col_type, id FROM t1_values';
--source suite/funcs_1/views/fv1.inc
let $col_type= my_varbinary_1000;
eval SET @my_select =
'SELECT LEFT($col_type, 2), $col_type, id FROM t1_values';
--source suite/funcs_1/views/fv1.inc
# Bug#11728 string function LEFT, strange undocumented behaviour, strict mode
# Bug#10963 LEFT string function returns wrong result with large length
let $col_type= my_bigint;
eval SET @my_select =
'SELECT LEFT(''AaBbCcDdEeFfGgHhIiJjÄäÜüÖö'', $col_type), $col_type, id FROM t1_values';
--source suite/funcs_1/views/fv1.inc
let $col_type= my_decimal;
eval SET @my_select =
'SELECT LEFT(''AaBbCcDdEeFfGgHhIiJjÄäÜüÖö'', $col_type), $col_type, id FROM t1_values';
--source suite/funcs_1/views/fv1.inc
# Bug#10963 LEFT string function returns wrong result with large length
let $col_type= my_double;
eval SET @my_select =
'SELECT LEFT(''AaBbCcDdEeFfGgHhIiJjÄäÜüÖö'', $col_type), $col_type, id FROM t1_values';
--source suite/funcs_1/views/fv1.inc
# 3.20. LENGTH(str)
let $col_type= my_char_30;
eval SET @my_select = 'SELECT LENGTH($col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type= my_varchar_1000;
eval SET @my_select = 'SELECT LENGTH($col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type= my_binary_30;
eval SET @my_select = 'SELECT LENGTH($col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type= my_varbinary_1000;
eval SET @my_select = 'SELECT LENGTH($col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
# 3.21. LOAD_FILE(file_name)
# Reads the file and returns the file contents as a string.
# If the file doesn't exist or cannot be read ... ,
# the function returns NULL.
# SELECT LOADFILE
--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
eval SET @my_select =
'SELECT LOAD_FILE(''$MYSQLTEST_VARDIR/std_data/funcs_1/load_file.txt'')
AS my_col,
id FROM t1_values';
--source suite/funcs_1/views/fv1.inc
# 3.22. LOCATE(substr,str) , LOCATE(substr,str,pos)
let $col_type= my_char_30;
eval SET @my_select = 'SELECT LOCATE(''char'', $col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type= my_varchar_1000;
eval SET @my_select = 'SELECT LOCATE(''char'', $col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type= my_binary_30;
eval SET @my_select = 'SELECT LOCATE(''char'', $col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type= my_varbinary_1000;
eval SET @my_select = 'SELECT LOCATE(''char'', $col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
#------------------------------------------------------
let $col_type1= my_char_30;
# against all other
eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type1 ),
$col_type1, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type2= my_varchar_1000;
eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),
$col_type1, $col_type2 id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type2= my_binary_30;
eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),
$col_type1, $col_type2 id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type2= my_varbinary_1000;
eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),
$col_type1, $col_type2 id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
#------------------------------------------------------
let $col_type1= my_varchar_1000;
# against all other
eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type1 ),
$col_type1, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type2= my_char_30;
eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),
$col_type1, $col_type2 id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type2= my_binary_30;
eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),
$col_type1, $col_type2 id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type2= my_varbinary_1000;
eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),
$col_type1, $col_type2 id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
#------------------------------------------------------
let $col_type1= my_binary_30;
# against all other
eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type1 ),
$col_type1, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type2= my_char_30;
eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),
$col_type1, $col_type2 id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type2= my_varchar_1000;
eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),
$col_type1, $col_type2 id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type2= my_varbinary_1000;
eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),
$col_type1, $col_type2 id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
#------------------------------------------------------
let $col_type1= my_varbinary_1000;
# against all other
eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type1 ),
$col_type1, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type2= my_char_30;
eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),
$col_type1, $col_type2 id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type2= my_varchar_1000;
eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),
$col_type1, $col_type2 id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type2= my_binary_30;
eval SET @my_select = 'SELECT LOCATE($col_type1, $col_type2 ),
$col_type1, $col_type2 id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
# FIXME How to test exotic or interesting substr values like NULL, '', ' '
# without getting too much result rows
# FIXME Testcases with LOCATE(substr,str,pos)
let $col_type= my_char_30;
eval SET @my_select = 'SELECT LOCATE(''-'', $col_type, 3),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type= my_varchar_1000;
eval SET @my_select = 'SELECT LOCATE(''-'', $col_type, 3),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type= my_binary_30;
eval SET @my_select = 'SELECT LOCATE(''-'', $col_type, 3),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type= my_varbinary_1000;
eval SET @my_select = 'SELECT LOCATE(''-'', $col_type, 3),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
#--------------------------------------------------------
let $col_type= my_bigint;
eval SET @my_select = 'SELECT LOCATE(''-'', '' - -ABC'', $col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type= my_double;
eval SET @my_select = 'SELECT LOCATE(''-'', '' - -ABC'', $col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type= my_decimal;
eval SET @my_select = 'SELECT LOCATE(''-'', '' - -ABC'', $col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
# 3.23. LOWER(str)
let $col_type= my_char_30;
eval SET @my_select = 'SELECT LOWER($col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type= my_varchar_1000;
eval SET @my_select = 'SELECT LOWER($col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type= my_binary_30;
eval SET @my_select = 'SELECT LOWER($col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type= my_varbinary_1000;
eval SET @my_select = 'SELECT LOWER($col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
# 3.24. LPAD(str,len,padstr)
# 3.25. LTRIM(str)
let $col_type= my_char_30;
eval SET @my_select = 'SELECT LTRIM($col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type= my_varchar_1000;
eval SET @my_select = 'SELECT LTRIM($col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type= my_binary_30;
eval SET @my_select = 'SELECT LTRIM($col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
let $col_type= my_varbinary_1000;
eval SET @my_select = 'SELECT LTRIM($col_type),
$col_type, id FROM t1_values';
--source suite/funcs_1/views/fv2.inc
# 3.26. MAKE_SET(bits,str1,str2,...)
# .....
# FIXME: to be implemented
################################################################################
# Please do not add SELECTs and interesting records after this line. #
# These last SELECTs are mostly for checking the testcase code itself. #
################################################################################
eval SET @my_select =
'SELECT CONCAT(''A'',my_char_30), my_char_30, id FROM t1_values'; #
--source suite/funcs_1/views/fv1.inc
#
eval SET @my_select = 'SELECT my_char_30, id FROM t1_values'; #
--source suite/funcs_1/views/fv2.inc
eval INSERT INTO t1_values SET select_id = @select_id,
my_char_30 = 'Viana do Castelo';
################################################################################
SET sql_mode = ''; #
##### END Basic preparations #######################################
let $message= "# The basic preparations end and the main test starts here";
--source include/show_msg80.inc
--disable_ps_protocol
##### The tests start here #####################################################
# Determine the number of different SELECTs to be checked
--disable_query_log
SELECT COUNT(*) INTO @num_selects FROM t1_selects;
--enable_query_log
# Debug statement
# SELECT @num_selects AS "number of SELECTS:";
--disable_abort_on_error
let $select_id= `SELECT @num_selects`;
while ($select_id)
{
# Determine the SELECT
--disable_query_log
eval SELECT my_select, disable_result INTO @my_select, @disable_result
FROM t1_selects WHERE id = $select_id;
let $run_no_result= `SELECT @disable_result = 'Yes'`;
--enable_query_log
# Debug statement
# SELECT @my_select AS "SELECT:";
let $my_select= `SELECT @my_select`;
let $run0= 0;
if ($view_select_result)
{
# Create the VIEW
--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
eval CREATE VIEW v1 AS $my_select;
--disable_query_log
eval set @got_errno= $mysql_errno ;
let $run0= `SELECT @got_errno = 0`;
--enable_query_log
if (!$run0)
{
--echo
--echo Attention: The last CREATE VIEW failed
--echo
}
}
# FIXME The loop over the modes will start here.
if ($simple_select_result)
{
# Simple SELECT on the base table of the VIEW for comparison
if ($run_no_result)
{
--disable_result_log
}
--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
eval $my_select
WHERE select_id = $select_id OR select_id IS NULL order by id;
if ($run_no_result)
{
--enable_result_log
}
if ($mysql_errno)
{
--echo
--echo Attention: The last SELECT on the base table failed
--echo
}
}
# $run0 is 1, if CREATE VIEW was successful.
# That means SHOW CREATE VIEW/SELECT/DROP should be executed.
if ($run0)
{
# Check the CREATE VIEW statement
--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
SHOW CREATE VIEW v1;
if ($mysql_errno)
{
--echo
--echo Attention: The last SHOW CREATE VIEW failed
--echo
}
# Maybe a Join is faster
if ($run_no_result)
{
--disable_result_log
}
eval SELECT v1.* FROM v1
WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = $select_id OR select_id IS NULL) order by id;
if ($run_no_result)
{
--enable_result_log
}
if ($mysql_errno)
{
--echo
--echo Attention: The last SELECT from VIEW failed
--echo
}
DROP VIEW v1;
}
# FIXME The loop over the modes will end here.
# Produce two empty lines as separator between different SELECTS
# to be tested.
--echo
--echo
dec $select_id ;
}
--enable_ps_protocol
DROP TABLE t1_selects, t1_modes, t1_values;
SET timestamp=DEFAULT;
|