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
|
# 2024 March 3
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix values
do_execsql_test 1.0 {
CREATE TABLE x1(a, b, c);
}
explain_i {
INSERT INTO x1(a, b, c) VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4);
}
do_execsql_test 1.1.1 {
INSERT INTO x1 VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4);
}
do_execsql_test 1.1.2 {
SELECT * FROM x1;
} {
1 1 1
2 2 2
3 3 3
4 4 4
}
do_execsql_test 1.2.0 {
DELETE FROM x1
}
do_execsql_test 1.2.1 {
INSERT INTO x1 VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3) UNION ALL SELECT 4, 4, 4;
SELECT * FROM x1;
} {1 1 1 2 2 2 3 3 3 4 4 4}
sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT 4
do_execsql_test 1.2.2 {
DELETE FROM x1;
INSERT INTO x1
VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5)
UNION ALL SELECT 6, 6, 6;
SELECT * FROM x1;
} {1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6}
do_execsql_test 1.2.3 {
DELETE FROM x1;
INSERT INTO x1
VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4)
UNION ALL SELECT 6, 6, 6;
SELECT * FROM x1;
} {1 1 1 2 2 2 3 3 3 4 4 4 6 6 6}
do_execsql_test 1.2.4 {
DELETE FROM x1;
INSERT INTO x1 VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3) UNION ALL SELECT 6, 6, 6;
SELECT * FROM x1;
} {
1 1 1
2 2 2
3 3 3
6 6 6
}
set a 4
set b 5
set c 6
do_execsql_test 1.2.5 {
DELETE FROM x1;
INSERT INTO x1
VALUES(1, 1, 1), (2, 2, 2), (3, 3, 3),
(4, 4, $a), (5, 5, $b), (6, 6, $c)
}
do_execsql_test 1.2.6 {
SELECT * FROM x1;
} {
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
}
#-------------------------------------------------------------------------
# SQLITE_LIMIT_COMPOUND_SELECT set to 0.
#
reset_db
do_execsql_test 2.0 {
CREATE TABLE x1(a, b, c);
}
sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT 3
do_catchsql_test 2.1.1 {
INSERT INTO x1 VALUES
(1, 1, 1),
(2, 2, 2),
(3, 3, 3),
(4, 4, 4),
(5, 5, 5),
(6, 6, 6),
(7, 7, 7),
(8, 8, 8),
(9, 9, 9),
(10, 10, 10, 10)
} {1 {all VALUES must have the same number of terms}}
do_catchsql_test 2.1.2 {
INSERT INTO x1 VALUES
(1, 1, 1),
(2, 2, 2, 2),
(3, 3, 3),
(4, 4, 4),
(5, 5, 5),
(6, 6, 6),
(7, 7, 7),
(8, 8, 8),
(9, 9, 9),
(10, 10, 10)
} {1 {all VALUES must have the same number of terms}}
sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT 0
do_execsql_test 2.2 {
INSERT INTO x1 VALUES
(1, 1, 1),
(2, 2, 2),
(3, 3, 3),
(4, 4, 4),
(5, 5, 5),
(6, 6, 6),
(7, 7, 7),
(8, 8, 8),
(9, 9, 9),
(10, 10, 10)
} {}
do_execsql_test 2.3 {
INSERT INTO x1 VALUES
(1, 1, 1),
(2, 2, 2),
(3, 3, 3),
(4, 4, 4),
(5, 5, 5),
(6, 6, 6),
(7, 7, 7),
(8, 8, 8),
(9, 9, 9),
(10, 10, 10)
UNION ALL
SELECT 5, 12, 12
ORDER BY 1
} {}
#-------------------------------------------------------------------------
reset_db
do_execsql_test 3.0 {
CREATE TABLE y1(x, y);
}
do_execsql_test 3.1.1 {
DELETE FROM y1;
INSERT INTO y1 VALUES(1, 2), (3, 4), (row_number() OVER (), 5);
}
do_execsql_test 3.1.2 {
SELECT * FROM y1;
} {1 2 3 4 1 5}
do_execsql_test 3.2.1 {
DELETE FROM y1;
INSERT INTO y1 VALUES(1, 2), (3, 4), (row_number() OVER (), 6)
, (row_number() OVER (), 7)
}
do_execsql_test 3.1.2 {
SELECT * FROM y1;
} {1 2 3 4 1 6 1 7}
#-------------------------------------------------------------------------
reset_db
do_execsql_test 4.0 {
CREATE TABLE x1(a PRIMARY KEY, b) WITHOUT ROWID;
}
foreach {tn iLimit} {1 0 2 3} {
sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT $iLimit
do_execsql_test 4.1.1 {
DELETE FROM x1;
INSERT INTO x1 VALUES
(1, 1),
(2, (SELECT * FROM (VALUES('a'), ('b'), ('c'), ('d')) ))
}
do_execsql_test 4.1.2 {
SELECT * FROM x1
} {1 1 2 a}
do_execsql_test 4.2.1 {
DELETE FROM x1;
INSERT INTO x1 VALUES
(1, 1),
(2, 2),
(3, 3),
(4, 4),
(5, (SELECT * FROM (VALUES('a'), ('b'), ('c'), ('d')) ))
}
do_execsql_test 4.2.2 {
SELECT * FROM x1
} {1 1 2 2 3 3 4 4 5 a}
do_execsql_test 4.3.1 {
DELETE FROM x1;
INSERT INTO x1 VALUES
(1, (SELECT * FROM (VALUES('a'), ('b'), ('c'), ('d'), ('e')) ))
}
do_execsql_test 4.3.2 {
SELECT * FROM x1
} {1 a}
}
#------------------------------------------------------------------------
reset_db
do_execsql_test 5.0 {
CREATE VIEW v1 AS VALUES(1, 2, 3), (4, 5, 6), (7, 8, 9);
}
do_execsql_test 5.1 {
SELECT * FROM v1
} {1 2 3 4 5 6 7 8 9}
#-------------------------------------------------------------------------
reset_db
do_execsql_test 6.0 {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(1), (2);
}
do_execsql_test 6.1 {
SELECT ( VALUES( x ), ( x ) ) FROM t1;
} {1 2}
#-------------------------------------------------------------------------
reset_db
do_execsql_test 6.0 {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES('x'), ('y');
}
do_execsql_test 6.1 {
SELECT * FROM t1, (VALUES(1), (2))
} {x 1 x 2 y 1 y 2}
do_execsql_test 6.2 {
VALUES(CAST(44 AS REAL)),(55);
} {44.0 55}
#------------------------------------------------------------------------
do_execsql_test 7.1 {
WITH x1(a, b) AS (
VALUES(1, 2), ('a', 'b')
)
SELECT * FROM x1 one, x1 two
} {
1 2 1 2
1 2 a b
a b 1 2
a b a b
}
#-------------------------------------------------------------------------
reset_db
set VVV {
( VALUES('a', 'b'), ('c', 'd'), (123, NULL) )
}
set VVV2 {
(
SELECT 'a' AS column1, 'b' AS column2
UNION ALL SELECT 'c', 'd' UNION ALL SELECT 123, NULL
)
}
do_execsql_test 8.0 {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES('d'), (NULL), (123)
}
foreach {tn q res} {
1 "SELECT * FROM t1 LEFT JOIN VVV" {
d a b d c d d 123 {}
{} a b {} c d {} 123 {}
123 a b 123 c d 123 123 {}
}
2 "SELECT * FROM t1 LEFT JOIN VVV ON (column1=x)" {
d {} {}
{} {} {}
123 123 {}
}
3 "SELECT * FROM t1 RIGHT JOIN VVV" {
d a b d c d d 123 {}
{} a b {} c d {} 123 {}
123 a b 123 c d 123 123 {}
}
4 "SELECT * FROM t1 RIGHT JOIN VVV ON (column1=x)" {
123 123 {}
{} a b
{} c d
}
5 "SELECT * FROM t1 FULL OUTER JOIN VVV ON (column1=x)" {
d {} {}
{} {} {}
123 123 {}
{} a b
{} c d
}
6 "SELECT count(*) FROM VVV" { 3 }
7 "SELECT (SELECT column1 FROM VVV)" { a }
8 "SELECT * FROM VVV UNION ALL SELECT * FROM VVV" {
a b c d 123 {}
a b c d 123 {}
}
9 "SELECT * FROM VVV INTERSECT SELECT * FROM VVV" {
123 {} a b c d
}
10 "SELECT * FROM VVV eXCEPT SELECT * FROM VVV" { }
11 "SELECT * FROM VVV eXCEPT SELECT 'a', 'b'" { 123 {} c d }
} {
set q1 [string map [list VVV $VVV] $q]
set q2 [string map [list VVV $VVV2] $q]
set q3 "WITH VVV AS $VVV $q"
do_execsql_test 8.1.$tn.1 $q1 $res
do_execsql_test 8.1.$tn.2 $q2 $res
do_execsql_test 8.1.$tn.3 $q3 $res
}
#-------------------------------------------------------------------------
reset_db
do_execsql_test 9.1 {
VALUES(456), (123), (NULL) UNION ALL SELECT 122 ORDER BY 1
} { {} 122 123 456 }
do_execsql_test 9.2 {
VALUES (1, 2), (3, 4), (
( SELECT column1 FROM ( VALUES (5, 6), (7, 8) ) ),
( SELECT max(column2) FROM ( VALUES (5, 1), (7, 6) ) )
)
} { 1 2 3 4 5 6 }
do_execsql_test 10.1 {
CREATE TABLE a2(a, b, c DEFAULT 'xyz');
}
do_execsql_test 10.2 {
INSERT INTO a2(a) VALUES(3),(4);
}
#-------------------------------------------------------------------------
reset_db
ifcapable fts5 {
do_execsql_test 11.0 {
CREATE VIRTUAL TABLE ft USING fts3(x);
}
do_execsql_test 11.1 {
INSERT INTO ft VALUES('one'), ('two');
}
}
#-------------------------------------------------------------------------
reset_db
do_execsql_test 12.0 {
CREATE TABLE t1(a, b);
}
do_execsql_test 12.1 {
INSERT INTO t1 SELECT 1, 2 UNION ALL VALUES(3, 4), (5, 6);
}
do_execsql_test 12.2 {
SELECT * FROM t1
} {1 2 3 4 5 6}
#-------------------------------------------------------------------------
reset_db
do_execsql_test 13.0 {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES('xyz');
SELECT (
VALUES( (max(substr('abc', 1, 1), x)) ),
(123),
(456)
)
FROM t1;
} {xyz}
do_catchsql_test 13.1 {
VALUES(300), (zeroblob(300) OVER win);
} {1 {zeroblob() may not be used as a window function}}
#--------------------------------------------------------------------------
reset_db
do_execsql_test 14.1 {
PRAGMA encoding = utf16;
CREATE TABLE t1(a, b);
} {}
db close
sqlite3 db test.db
do_execsql_test 14.2 {
INSERT INTO t1 VALUES
(17, 'craft'),
(16, 'urtlek' IN(1,2,3));
}
#--------------------------------------------------------------------------
#
reset_db
do_eqp_test 15.1 {
VALUES(1),(2),(3),(4),(5);
} {
QUERY PLAN
`--SCAN 5-ROW VALUES CLAUSE
}
do_execsql_test 15.2 {
CREATE TABLE t1(a,b);
}
do_eqp_test 15.3 {
INSERT INTO t1 VALUES
(1,2),(3,4),(7,8);
} {
QUERY PLAN
`--SCAN 3-ROW VALUES CLAUSE
}
do_eqp_test 15.4 {
INSERT INTO t1 VALUES
(1,2),(3,4),(7,8),
(5,row_number()OVER());
} {
QUERY PLAN
`--COMPOUND QUERY
|--LEFT-MOST SUBQUERY
| `--SCAN 3-ROW VALUES CLAUSE
`--UNION ALL
|--CO-ROUTINE (subquery-xxxxxx)
| `--SCAN CONSTANT ROW
`--SCAN (subquery-xxxxxx)
}
do_eqp_test 15.5 {
SELECT * FROM (VALUES(1),(2),(3),(4),(5),(6)), (VALUES('a'),('b'),('c'));
} {
QUERY PLAN
|--SCAN 6-ROW VALUES CLAUSE
`--SCAN 3-ROW VALUES CLAUSE
}
do_execsql_test 15.6 {
CREATE TABLE t2(x,y);
}
do_eqp_test 15.7 {
SELECT * FROM t2 UNION ALL VALUES(1,2),(3,4),(5,6),(7,8);
} {
QUERY PLAN
`--COMPOUND QUERY
|--LEFT-MOST SUBQUERY
| `--SCAN t2
`--UNION ALL
`--SCAN 4-ROW VALUES CLAUSE
}
#--------------------------------------------------------------------------
# The VALUES-as-coroutine optimization can be applied to later rows of
# a VALUES clause even if earlier rows do not qualify.
#
reset_db
do_execsql_test 16.1 {
CREATE TABLE t1(a,b);
}
do_execsql_test 16.2 {
BEGIN;
INSERT INTO t1 VALUES(1,2),(3,4),(5,6),
(7,row_number()OVER()),
(9,10), (11,12), (13,14), (15,16);
SELECT * FROM t1 ORDER BY a, b;
ROLLBACK;
} {1 2 3 4 5 6 7 1 9 10 11 12 13 14 15 16}
do_eqp_test 16.3 {
INSERT INTO t1 VALUES(1,2),(3,4),(5,6),
(7,row_number()OVER()),
(9,10), (11,12), (13,14), (15,16);
} {
QUERY PLAN
`--COMPOUND QUERY
|--LEFT-MOST SUBQUERY
| `--SCAN 3-ROW VALUES CLAUSE
|--UNION ALL
| |--CO-ROUTINE (subquery-xxxxxx)
| | `--SCAN CONSTANT ROW
| `--SCAN (subquery-xxxxxx)
`--UNION ALL
`--SCAN 4-ROW VALUES CLAUSE
}
do_execsql_test 16.4 {
BEGIN;
INSERT INTO t1 VALUES
(1,row_number()OVER()),
(2,3), (4,5), (6,7);
SELECT * FROM t1 ORDER BY a, b;
ROLLBACK;
} {1 1 2 3 4 5 6 7}
do_eqp_test 16.5 {
INSERT INTO t1 VALUES
(1,row_number()OVER()),
(2,3), (4,5), (6,7);
} {
QUERY PLAN
`--COMPOUND QUERY
|--LEFT-MOST SUBQUERY
| |--CO-ROUTINE (subquery-xxxxxx)
| | `--SCAN CONSTANT ROW
| `--SCAN (subquery-xxxxxx)
`--UNION ALL
`--SCAN 3-ROW VALUES CLAUSE
}
do_execsql_test 16.6 {
BEGIN;
INSERT INTO t1 VALUES
(1,2),(3,4),
(5,row_number()OVER()),
(7,8),(9,10),(11,12),
(13,row_number()OVER()),
(15,16),(17,18),(19,20),(21,22);
SELECT * FROM t1 ORDER BY a, b;
ROLLBACK;
} { 1 2 3 4 5 1 7 8 9 10 11 12 13 1 15 16 17 18 19 20 21 22}
do_eqp_test 16.7 {
INSERT INTO t1 VALUES
(1,2),(3,4),
(5,row_number()OVER()),
(7,8),(9,10),(11,12),
(13,row_number()OVER()),
(15,16),(17,18),(19,20),(21,22);
} {
QUERY PLAN
`--COMPOUND QUERY
|--LEFT-MOST SUBQUERY
| `--SCAN 2-ROW VALUES CLAUSE
|--UNION ALL
| |--CO-ROUTINE (subquery-xxxxxx)
| | `--SCAN CONSTANT ROW
| `--SCAN (subquery-xxxxxx)
|--UNION ALL
| `--SCAN 3-ROW VALUES CLAUSE
|--UNION ALL
| |--CO-ROUTINE (subquery-xxxxxx)
| | `--SCAN CONSTANT ROW
| `--SCAN (subquery-xxxxxx)
`--UNION ALL
`--SCAN 4-ROW VALUES CLAUSE
}
#--------------------------------------------------------------------------
# 2024-03-23 dbsqlfuzz crash-c2c5e7e08b7e489d270a26d895077a03f678c33b
#
do_execsql_test 17.1 {
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 AS SELECT * FROM (VALUES(1,2), (3,4 IN (1,2,3)));
}
do_execsql_test 17.2 {
SELECT * FROM t1
} {1 2 3 0}
# 2024-03-25 dbsqlfuzz crash-74cf7c9904360322a6c917e4934b127543d1cd51
#
do_catchsql_test 18.1 {
DROP TABLE t1;
CREATE TABLE t1(x INTEGER PRIMARY KEY);
INSERT INTO t1 VALUES(RAISE(IGNORE)),(0);
} {1 {RAISE() may only be used within a trigger-program}}
do_catchsql_test 18.2 {
DROP TABLE t1;
CREATE TABLE t1(x INTEGER PRIMARY KEY, y, z);
CREATE TRIGGER r2 AFTER INSERT ON t1 BEGIN
INSERT INTO t1(y) VALUES(RAISE(IGNORE)),(0);
END;
INSERT INTO t1 VALUES(1,2,3);
SELECT * FROM t1;
} {0 {1 2 3}}
do_catchsql_test 18.3.1 {
DROP TABLE t1;
CREATE TABLE t1(x INTEGER PRIMARY KEY, y, z);
CREATE TRIGGER r2 AFTER INSERT ON t1 BEGIN
INSERT INTO t1(y) VALUES(RAISE(ABORT,'error 18.3')),(0);
END;
INSERT INTO t1 VALUES(1,2,3);
} {1 {error 18.3}}
do_execsql_test 18.3.2 {
SELECT * FROM t1;
} {}
do_catchsql_test 18.4.1 {
DROP TABLE t1;
CREATE TABLE t1(x INTEGER PRIMARY KEY, y, z);
CREATE TRIGGER r2 AFTER INSERT ON t1 BEGIN
INSERT INTO t1(y) VALUES(1),(RAISE(ABORT,'error 18.4')),(0);
END;
INSERT INTO t1 VALUES(1,2,3);
} {1 {error 18.4}}
do_execsql_test 18.4.2 {
SELECT * FROM t1;
} {}
do_catchsql_test 18.5.1 {
DROP TABLE t1;
CREATE TABLE t1(x INTEGER PRIMARY KEY, y, z);
CREATE TRIGGER r2 AFTER INSERT ON t1 BEGIN
INSERT INTO t1(y) VALUES(1),
(CASE WHEN new.z>7 THEN RAISE(ABORT,'error 18.5') ELSE 2 END);
END;
INSERT INTO t1 VALUES(1,2,3);
SELECT * FROM t1;
} {0 {1 2 3 2 1 {} 3 2 {}}}
do_catchsql_test 18.5.2 {
DELETE FROM t1;
INSERT INTO t1 VALUES(1,2,13);
} {1 {error 18.5}}
do_catchsql_test 18.5.3 {
SELECT * FROM t1;
} {0 {}}
# 2024-04-18 dbsqlfuzz crash-bde3bf80aedf25afa56e2997a0545a314765d3f8
# Verify that the VALUES expressions used as an argument to an outer
# join work correctly.
#
reset_db
db null NULL
do_execsql_test 19.1 {
CREATE TABLE t1(a INT, b INT);
INSERT INTO t1 VALUES(11,22);
SELECT * FROM t1 LEFT JOIN (VALUES(33,44),(55,66)) AS t2 ON a=b;
} {11 22 NULL NULL}
do_execsql_test 19.2 {
SELECT * FROM (VALUES(33,44),(55,66)) AS t2 RIGHT JOIN t1 ON a=b;
} {NULL NULL 11 22}
do_execsql_test 19.3 {
SELECT *, '|' FROM t1 FULL JOIN (VALUES(33,44),(55,66)) AS t2 ON a=b
ORDER BY +column1
} {11 22 NULL NULL | NULL NULL 33 44 | NULL NULL 55 66 |}
do_execsql_test 19.4 {
SELECT *, '|' FROM (VALUES(33,44),(55,66)) AS t2 FULL JOIN t1 ON a=b
ORDER BY +column1
} {NULL NULL 11 22 | 33 44 NULL NULL | 55 66 NULL NULL |}
# 2024-04-21 dbsqlfuzz 6fd1ff3a64bef4a6c092e8d757548e95698b0df5
# A continuation of the 2024-04-18 problem above. We have to create
# Pseudo-cursor that is always NULL on the viaCoroutine loop in case
# there are OP_Columns generated against it by the sub-WHERE clause.
#
db null N
do_execsql_test 19.5 {
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS t3;
CREATE TABLE t1(a,b); INSERT INTO t1 VALUES(1,2);
CREATE TABLE t2(column1,column2); INSERT INTO t2 VALUES(11,22),(33,44);
CREATE TABLE t3(d,e); INSERT INTO t3 VALUES(3,4);
}
do_execsql_test 19.6 {
-- output verify using PG 14.2
SELECT *
FROM t1 CROSS JOIN t2 FULL JOIN t3 ON a=d
ORDER BY +d, +column1;
} {1 2 11 22 N N
1 2 33 44 N N
N N N N 3 4}
do_execsql_test 19.7 {
SELECT *
FROM t1 CROSS JOIN (VALUES(11,22),(33,44)) FULL JOIN t3 ON a=d
ORDER BY +d, +column1;
} {1 2 11 22 N N
1 2 33 44 N N
N N N N 3 4}
do_execsql_test 19.8 {
-- output verified using PG 14.2
SELECT *
FROM t1 CROSS JOIN t2 FULL JOIN t3 ON a=d
WHERE column1 IS NULL;
} {N N N N 3 4}
do_execsql_test 19.9 {
SELECT *
FROM t1 CROSS JOIN (VALUES(11,22),(33,44)) FULL JOIN t3 ON a=d
WHERE column1 IS NULL;
} {N N N N 3 4}
finish_test
|