~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/suite/funcs_1/views/func_view.inc

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

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