-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
parse_test.go
3496 lines (3194 loc) · 151 KB
/
parse_test.go
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
// Copyright 2015 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
package parser_test
import (
"fmt"
"go/constant"
"reflect"
"regexp"
"strings"
"testing"
"github.com/cockroachdb/cockroach/pkg/sql/parser"
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
_ "github.com/cockroachdb/cockroach/pkg/sql/sem/builtins"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/testutils"
"github.com/cockroachdb/cockroach/pkg/testutils/sqlutils"
_ "github.com/cockroachdb/cockroach/pkg/util/log" // for flags
"github.com/cockroachdb/datadriven"
"github.com/cockroachdb/errors"
"github.com/stretchr/testify/assert"
)
// TestParse verifies that we can parse the supplied SQL and regenerate the SQL
// string from the syntax tree. If the supplied SQL generates a different string
// from the sytnax tree, use TestParse2 below.
func TestParse(t *testing.T) {
testData := []struct {
sql string
}{
{``},
{`VALUES ("")`},
{`BEGIN TRANSACTION`},
{`BEGIN TRANSACTION READ ONLY`},
{`BEGIN TRANSACTION READ WRITE`},
{`BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE`},
{`BEGIN TRANSACTION PRIORITY LOW`},
{`BEGIN TRANSACTION PRIORITY NORMAL`},
{`BEGIN TRANSACTION PRIORITY HIGH`},
{`BEGIN TRANSACTION AS OF SYSTEM TIME '2018-12-18'`},
{`BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, AS OF SYSTEM TIME '2018-12-18'`},
{`BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY LOW, AS OF SYSTEM TIME '2018-12-18'`},
{`BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY LOW, READ ONLY, AS OF SYSTEM TIME '-1ns'`},
{`BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH`},
{`BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH, READ WRITE`},
{`COMMIT TRANSACTION`},
{`ROLLBACK TRANSACTION`},
{`SAVEPOINT foo`},
{`SAVEPOINT "foo bar"`},
{`CREATE DATABASE a`},
{`EXPLAIN CREATE DATABASE a`},
{`CREATE DATABASE a TEMPLATE = 'template0'`},
{`CREATE DATABASE a TEMPLATE = 'invalid'`},
{`CREATE DATABASE a ENCODING = 'UTF8'`},
{`CREATE DATABASE a ENCODING = 'INVALID'`},
{`CREATE DATABASE a LC_COLLATE = 'C.UTF-8'`},
{`CREATE DATABASE a LC_COLLATE = 'INVALID'`},
{`CREATE DATABASE a LC_CTYPE = 'C.UTF-8'`},
{`CREATE DATABASE a LC_CTYPE = 'INVALID'`},
{`CREATE DATABASE a TEMPLATE = 'template0' ENCODING = 'UTF8' LC_COLLATE = 'C.UTF-8' LC_CTYPE = 'INVALID'`},
{`CREATE DATABASE a CONNECTION LIMIT = 13`},
{`CREATE DATABASE a REGIONS = "us-west-1", "us-west-2"`},
{`CREATE DATABASE a SURVIVE REGION FAILURE`},
{`CREATE DATABASE a SURVIVE ZONE FAILURE`},
{`CREATE DATABASE a PRIMARY REGION "us-west-1"`},
{`CREATE DATABASE IF NOT EXISTS a`},
{`CREATE DATABASE IF NOT EXISTS a TEMPLATE = 'template0'`},
{`CREATE DATABASE IF NOT EXISTS a TEMPLATE = 'invalid'`},
{`CREATE DATABASE IF NOT EXISTS a ENCODING = 'UTF8'`},
{`CREATE DATABASE IF NOT EXISTS a ENCODING = 'INVALID'`},
{`CREATE DATABASE IF NOT EXISTS a LC_COLLATE = 'C.UTF-8'`},
{`CREATE DATABASE IF NOT EXISTS a LC_COLLATE = 'INVALID'`},
{`CREATE DATABASE IF NOT EXISTS a LC_CTYPE = 'C.UTF-8'`},
{`CREATE DATABASE IF NOT EXISTS a LC_CTYPE = 'INVALID'`},
{`CREATE DATABASE IF NOT EXISTS a TEMPLATE = 'template0' ENCODING = 'UTF8' LC_COLLATE = 'C.UTF-8' LC_CTYPE = 'INVALID'`},
{`CREATE DATABASE IF NOT EXISTS a REGIONS = "us-west-1", "us-west-2"`},
{`CREATE DATABASE IF NOT EXISTS a SURVIVE REGION FAILURE`},
{`CREATE DATABASE IF NOT EXISTS a SURVIVE ZONE FAILURE`},
{`CREATE DATABASE IF NOT EXISTS a PRIMARY REGION "us-west-1"`},
{`CREATE SCHEMA IF NOT EXISTS foo`},
{`CREATE SCHEMA foo`},
{`CREATE SCHEMA IF NOT EXISTS foo.bar`},
{`CREATE SCHEMA foo.bar`},
{`CREATE SCHEMA IF NOT EXISTS foo AUTHORIZATION foobar`},
{`CREATE SCHEMA IF NOT EXISTS foo.bar AUTHORIZATION foobar`},
{`CREATE SCHEMA foo AUTHORIZATION foobar`},
{`CREATE SCHEMA foo.bar AUTHORIZATION foobar`},
{`CREATE SCHEMA IF NOT EXISTS AUTHORIZATION foobar`},
{`CREATE SCHEMA AUTHORIZATION foobar`},
{`CREATE INDEX a ON b (c)`},
{`CREATE INDEX CONCURRENTLY a ON b (c)`},
{`EXPLAIN CREATE INDEX a ON b (c)`},
{`CREATE INDEX a ON b.c (d)`},
{`CREATE INDEX ON a (b)`},
{`CREATE INDEX ON a (b) STORING (c)`},
{`CREATE INDEX ON a (b) WHERE c > 3`},
{`CREATE INDEX ON a (b) INTERLEAVE IN PARENT c (d)`},
{`CREATE INDEX ON a (b) INTERLEAVE IN PARENT c.d (e)`},
{`CREATE INDEX ON a (b ASC, c DESC)`},
{`CREATE INDEX ON a (b NULLS FIRST, c ASC NULLS FIRST, d DESC NULLS LAST)`},
{`CREATE INDEX IF NOT EXISTS i ON a (b) WHERE c > 3`},
{`CREATE UNIQUE INDEX a ON b (c)`},
{`CREATE UNIQUE INDEX a ON b (c) STORING (d)`},
{`CREATE UNIQUE INDEX a ON b (c) WHERE d > 3`},
{`CREATE UNIQUE INDEX a ON b (c) INTERLEAVE IN PARENT d (e, f)`},
{`CREATE UNIQUE INDEX a ON b (c) INTERLEAVE IN PARENT d.e (f, g)`},
{`CREATE UNIQUE INDEX a ON b.c (d)`},
{`CREATE INVERTED INDEX a ON b (c)`},
{`CREATE INVERTED INDEX a ON b.c (d)`},
{`CREATE INVERTED INDEX a ON b (c) STORING (d)`},
{`CREATE INVERTED INDEX a ON b (c) WHERE d > 3`},
{`CREATE INVERTED INDEX a ON b (c) INTERLEAVE IN PARENT d (e)`},
{`CREATE INVERTED INDEX IF NOT EXISTS a ON b (c) WHERE d > 3`},
{`CREATE INDEX a ON b (c) WITH (fillfactor = 100, y_bounds = 50)`},
{`CREATE INDEX ON a ((a + b))`},
{`CREATE INDEX ON a (lower(a))`},
{`CREATE INDEX ON a (a, lower(b))`},
{`CREATE INDEX ON a (((lower(a) || ' ') || lower(b)))`},
{`CREATE INDEX ON a (a, (a + 1), (b + 2))`},
{`CREATE INDEX ON a (lower(a))`},
{`CREATE INDEX ON a (lower(a), lower(b))`},
{`CREATE INDEX ON a (a, lower(b))`},
{`CREATE INDEX ON a (((lower(a) || ' ') || lower(b)))`},
{`CREATE UNIQUE INDEX ON a ((a + b))`},
{`CREATE UNIQUE INDEX ON a (lower(a))`},
{`CREATE UNIQUE INDEX ON a (a, lower(b))`},
{`CREATE UNIQUE INDEX ON a (((lower(a) || ' ') || lower(b)))`},
{`CREATE UNIQUE INDEX ON a (a, (a + 1), (b + 2))`},
{`CREATE UNIQUE INDEX ON a (lower(a))`},
{`CREATE UNIQUE INDEX ON a (lower(a), lower(b))`},
{`CREATE UNIQUE INDEX ON a (a, lower(b))`},
{`CREATE UNIQUE INDEX ON a (((lower(a) || ' ') || lower(b)))`},
{`CREATE INVERTED INDEX ON a ((ARRAY[a, b]))`},
{`CREATE TABLE a ()`},
{`CREATE TEMPORARY TABLE a (b INT8)`},
{`CREATE UNLOGGED TABLE a (b INT8)`},
{`EXPLAIN CREATE TABLE a ()`},
{`CREATE TABLE a (b INT8)`},
{`CREATE TABLE a (b INT8, c INT8)`},
{`CREATE TABLE a (b CHAR)`},
{`CREATE TABLE a (b CHAR(3))`},
{`CREATE TABLE a (b VARCHAR)`},
{`CREATE TABLE a (b VARCHAR(3))`},
{`CREATE TABLE a (b STRING)`},
{`CREATE TABLE a (b STRING(3))`},
{`CREATE TABLE a (b FLOAT4)`},
{`CREATE TABLE a (b FLOAT8)`},
{`CREATE TABLE a (b SERIAL8)`},
{`CREATE TABLE a (b TIME)`},
{`CREATE TABLE a (b TIMETZ)`},
{`CREATE TABLE a (b TIME(3))`},
{`CREATE TABLE a (b TIMETZ(3))`},
{`CREATE TABLE a (b BOX2D)`},
{`CREATE TABLE a (b GEOGRAPHY)`},
{`CREATE TABLE a (b GEOGRAPHY(POINT))`},
{`CREATE TABLE a (b GEOGRAPHY(POINT,4326))`},
{`CREATE TABLE a (b GEOGRAPHY(LINESTRING,4326))`},
{`CREATE TABLE a (b GEOGRAPHY(POLYGON,4326))`},
{`CREATE TABLE a (b GEOGRAPHY(MULTIPOINT,4326))`},
{`CREATE TABLE a (b GEOGRAPHY(MULTILINESTRING,4326))`},
{`CREATE TABLE a (b GEOGRAPHY(MULTIPOLYGON,4326))`},
{`CREATE TABLE a (b GEOGRAPHY(GEOMETRY,4326))`},
{`CREATE TABLE a (b GEOGRAPHY(GEOMETRYCOLLECTION,4326))`},
{`CREATE TABLE a (b GEOMETRY)`},
{`CREATE TABLE a (b GEOMETRY(POINT))`},
{`CREATE TABLE a (b GEOMETRY(POINT,4326))`},
{`CREATE TABLE a (b UUID)`},
{`CREATE TABLE a (b INET)`},
{`CREATE TABLE a (b "char")`},
{`CREATE TABLE a (b INT8 NULL)`},
{`CREATE TABLE a (b INT8 CONSTRAINT maybe NULL)`},
{`CREATE TABLE a (b INT8 NOT NULL)`},
{`CREATE TABLE a (b INT8 CONSTRAINT always NOT NULL)`},
{`CREATE TABLE a (b INT8 PRIMARY KEY)`},
{`CREATE TABLE a (b INT8 UNIQUE)`},
{`CREATE TABLE a (b INT8 UNIQUE WITHOUT INDEX)`},
{`CREATE TABLE a (b INT8 NULL PRIMARY KEY)`},
{`CREATE TABLE a (b INT8 DEFAULT 1)`},
{`CREATE TABLE a (b INT8 CONSTRAINT one DEFAULT 1)`},
{`CREATE TABLE a (b INT8 DEFAULT now())`},
{`CREATE TABLE a (a INT8 CHECK (a > 0))`},
{`CREATE TABLE a (a INT8 CONSTRAINT positive CHECK (a > 0))`},
{`CREATE TABLE a (a INT8 DEFAULT 1 CHECK (a > 0))`},
{`CREATE TABLE a (a INT8 CONSTRAINT one DEFAULT 1 CHECK (a > 0))`},
{`CREATE TABLE a (a INT8 DEFAULT 1 CONSTRAINT positive CHECK (a > 0))`},
{`CREATE TABLE a (a INT8 CONSTRAINT one DEFAULT 1 CONSTRAINT positive CHECK (a > 0))`},
{`CREATE TABLE a (a INT8 CONSTRAINT one CHECK (a > 0) CONSTRAINT two CHECK (a < 10))`},
// "0" lost quotes previously.
{`CREATE TABLE a (b INT8, c STRING, PRIMARY KEY (b, c, "0"))`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON UPDATE RESTRICT)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT ON UPDATE RESTRICT)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON UPDATE CASCADE)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE ON UPDATE CASCADE)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON UPDATE SET NULL)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL ON UPDATE SET NULL)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON UPDATE SET DEFAULT)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT ON UPDATE SET DEFAULT)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT ON UPDATE SET DEFAULT)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT ON UPDATE CASCADE)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE ON UPDATE SET NULL)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL ON UPDATE RESTRICT)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other MATCH FULL ON DELETE SET DEFAULT ON UPDATE SET DEFAULT)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other MATCH FULL ON DELETE RESTRICT ON UPDATE SET DEFAULT)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other MATCH FULL ON DELETE SET DEFAULT ON UPDATE CASCADE)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other MATCH FULL ON DELETE CASCADE ON UPDATE SET NULL)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other MATCH FULL ON DELETE SET NULL ON UPDATE RESTRICT)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other MATCH FULL)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH FULL)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other)`},
{`CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y))`},
{`CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y))`},
{`CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH FULL)`},
{`CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH FULL ON UPDATE SET NULL)`},
{`CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH FULL ON DELETE SET DEFAULT)`},
{`CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH FULL ON DELETE SET DEFAULT ON UPDATE SET NULL)`},
{`CREATE TABLE a (b INT8, c STRING, INDEX (b, c))`},
{`CREATE TABLE a (b INT8, c STRING, INDEX d (b, c))`},
{`CREATE TABLE a (b INT8, c STRING, CONSTRAINT d UNIQUE (b, c))`},
{`CREATE TABLE a (b INT8, c STRING, CONSTRAINT d UNIQUE WITHOUT INDEX (b, c))`},
{`CREATE TABLE a (b INT8, c STRING, CONSTRAINT d UNIQUE (b, c) INTERLEAVE IN PARENT d (e, f))`},
{`CREATE TABLE a (b INT8, UNIQUE (b))`},
{`CREATE TABLE a (b INT8, UNIQUE (b) STORING (c))`},
{`CREATE TABLE a (b INT8, INDEX (b))`},
{`CREATE TABLE a (b INT8, INVERTED INDEX (b))`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE RESTRICT)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE RESTRICT)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE RESTRICT ON UPDATE RESTRICT)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE CASCADE)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE CASCADE)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE CASCADE ON UPDATE CASCADE)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE SET NULL)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE SET NULL)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE SET NULL ON UPDATE SET NULL)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE SET DEFAULT)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE SET DEFAULT)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE SET DEFAULT ON UPDATE SET DEFAULT)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE RESTRICT ON UPDATE SET DEFAULT)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE SET DEFAULT ON UPDATE CASCADE)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE CASCADE ON UPDATE SET NULL)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE SET NULL ON UPDATE RESTRICT)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE CASCADE)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE SET NULL)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE SET DEFAULT)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo (bar))`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo MATCH FULL)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo MATCH FULL ON UPDATE RESTRICT)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo MATCH FULL ON DELETE RESTRICT)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo MATCH FULL ON DELETE RESTRICT ON UPDATE RESTRICT)`},
{`CREATE TABLE a (b INT8, c INT8 REFERENCES foo (bar) MATCH FULL)`},
{`CREATE TABLE a (b INT8, INDEX (b) STORING (c))`},
{`CREATE TABLE a (b INT8, INDEX (b) WHERE b > 3)`},
{`CREATE TABLE a (b INT8, INVERTED INDEX (b) WHERE b > 3)`},
{`CREATE TABLE a (b INT8, c STRING, INDEX (b ASC, c DESC) STORING (c))`},
{`CREATE TABLE a (b INT8, INDEX (b) INTERLEAVE IN PARENT c (d, e))`},
{`CREATE TABLE a (b INT8, FAMILY (b))`},
{`CREATE TABLE a (b INT8, c STRING, FAMILY foo (b), FAMILY (c))`},
{`CREATE TABLE a (b INT8) INTERLEAVE IN PARENT foo (c, d)`},
{`CREATE TABLE a (b INT8) INTERLEAVE IN PARENT foo (c) CASCADE`},
{`CREATE TABLE a.b (b INT8)`},
{`CREATE TABLE IF NOT EXISTS a (b INT8)`},
{`CREATE TABLE a (b INT8 AS (a + b) STORED)`},
{`CREATE TABLE a (b INT8 AS (a + b) VIRTUAL)`},
{`CREATE TABLE view (view INT8)`},
{`CREATE TABLE a (b INT8 CONSTRAINT c PRIMARY KEY)`},
{`CREATE TABLE a (b INT8 CONSTRAINT c NULL)`},
{`CREATE TABLE a (b INT8 CONSTRAINT c UNIQUE)`},
{`CREATE TABLE a (b INT8 CONSTRAINT c UNIQUE WITHOUT INDEX)`},
{`CREATE TABLE a (b INT8 CONSTRAINT c DEFAULT d)`},
{`CREATE TABLE a (b INT8 CONSTRAINT c CHECK (d))`},
{`CREATE TABLE a (b INT8 CONSTRAINT c REFERENCES d)`},
{`CREATE TABLE a (b INT8) PARTITION BY LIST (b) (PARTITION p1 VALUES IN (1, DEFAULT), PARTITION p2 VALUES IN ((1, 2), (3, 4)))`},
// This monstrosity was added on the assumption that it's more readable
// than all on one line. Feel free to rip it out if you come across it
// and disagree.
{regexp.MustCompile(`\n\s*`).ReplaceAllLiteralString(
`CREATE TABLE a (b INT8, c INT8, d INT8) PARTITION BY LIST (b) (
PARTITION p1 VALUES IN (1) PARTITION BY LIST (c) (
PARTITION p1_1 VALUES IN (3), PARTITION p1_2 VALUES IN (4, 5)
), PARTITION p2 VALUES IN (6) PARTITION BY RANGE (c) (
PARTITION p2_1 VALUES FROM (7) TO (8) PARTITION BY LIST (d) (
PARTITION p2_1_1 VALUES IN (8)
)
)
)`, ``),
},
{`CREATE TABLE a () INTERLEAVE IN PARENT b (c) PARTITION BY LIST (d) (PARTITION e VALUES IN (1))`},
{`CREATE TABLE IF NOT EXISTS a () PARTITION BY LIST (b) (PARTITION c VALUES IN (1))`},
{`CREATE TABLE a (INDEX (b) PARTITION BY LIST (c) (PARTITION d VALUES IN (1)))`},
{`CREATE TABLE a (UNIQUE (b) PARTITION BY LIST (c) (PARTITION d VALUES IN (1)))`},
{`CREATE INDEX ON a (b) PARTITION BY LIST (c) (PARTITION d VALUES IN (1))`},
{`CREATE INDEX IF NOT EXISTS a ON b (c) PARTITION BY LIST (d) (PARTITION e VALUES IN (1))`},
{`ALTER TABLE a PARTITION BY LIST (b) (PARTITION p1 VALUES IN (1))`},
{`ALTER INDEX a@idx PARTITION BY LIST (b) (PARTITION p1 VALUES IN (1))`},
{`CREATE TABLE a AS SELECT * FROM b`},
{`CREATE TABLE IF NOT EXISTS a AS SELECT * FROM b`},
{`CREATE TABLE a AS SELECT * FROM b ORDER BY c`},
{`CREATE TABLE IF NOT EXISTS a AS SELECT * FROM b ORDER BY c`},
{`CREATE TABLE a AS SELECT * FROM b LIMIT 3`},
{`CREATE TABLE IF NOT EXISTS a AS SELECT * FROM b LIMIT 3`},
{`CREATE TABLE a AS VALUES ('one', 1), ('two', 2), ('three', 3)`},
{`CREATE TABLE IF NOT EXISTS a AS VALUES ('one', 1), ('two', 2), ('three', 3)`},
{`CREATE TABLE a (str, num) AS VALUES ('one', 1), ('two', 2), ('three', 3)`},
{`CREATE TABLE IF NOT EXISTS a (str, num) AS VALUES ('one', 1), ('two', 2), ('three', 3)`},
{`CREATE TABLE a AS SELECT * FROM b UNION SELECT * FROM c`},
{`CREATE TABLE IF NOT EXISTS a AS SELECT * FROM b UNION SELECT * FROM c`},
{`CREATE TABLE a AS SELECT * FROM b UNION VALUES ('one', 1) ORDER BY c LIMIT 5`},
{`CREATE TABLE IF NOT EXISTS a AS SELECT * FROM b UNION VALUES ('one', 1) ORDER BY c LIMIT 5`},
{`CREATE TABLE a (z PRIMARY KEY) AS SELECT * FROM b`},
{`CREATE TABLE IF NOT EXISTS a (z PRIMARY KEY) AS SELECT * FROM b`},
{`CREATE TABLE a (x, y, z, PRIMARY KEY (x, y, z)) AS SELECT * FROM b`},
{`CREATE TABLE IF NOT EXISTS a (x, y, z, PRIMARY KEY (x, y, z)) AS SELECT * FROM b`},
{`CREATE TABLE a (x, FAMILY (x)) AS SELECT * FROM b`},
{`CREATE TABLE IF NOT EXISTS a (x, FAMILY (x)) AS SELECT * FROM b`},
{`CREATE TABLE a (x, y FAMILY f1) AS SELECT * FROM b`},
{`CREATE TABLE IF NOT EXISTS a (x, y FAMILY f1) AS SELECT * FROM b`},
{`CREATE TABLE a (b STRING COLLATE de)`},
{`CREATE TABLE a (b STRING(3) COLLATE de)`},
{`CREATE TABLE a (b STRING[] COLLATE de)`},
{`CREATE TABLE a (b STRING(3)[] COLLATE en_US)`},
{`CREATE TABLE a (LIKE b)`},
{`CREATE TABLE a (LIKE b, c INT8)`},
{`CREATE TABLE a (LIKE b EXCLUDING INDEXES INCLUDING INDEXES)`},
{`CREATE TABLE a (LIKE b INCLUDING ALL EXCLUDING INDEXES, c INT8)`},
{`CREATE TABLE a (a INT4) LOCALITY GLOBAL`},
{`CREATE TABLE a (a INT4) LOCALITY REGIONAL BY TABLE IN "us-west1"`},
{`CREATE TABLE a (a INT4) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION`},
{`CREATE TABLE a (a INT4) LOCALITY REGIONAL BY ROW`},
{`CREATE VIEW a AS SELECT * FROM b`},
{`CREATE OR REPLACE VIEW a AS SELECT * FROM b`},
{`EXPLAIN CREATE VIEW a AS SELECT * FROM b`},
{`CREATE VIEW a AS SELECT b.* FROM b LIMIT 5`},
{`CREATE VIEW a AS (SELECT c, d FROM b WHERE c > 0 ORDER BY c)`},
{`CREATE VIEW a (x, y) AS SELECT c, d FROM b`},
{`CREATE VIEW a AS VALUES (1, 'one'), (2, 'two')`},
{`CREATE VIEW a (x, y) AS VALUES (1, 'one'), (2, 'two')`},
{`CREATE VIEW a AS TABLE b`},
{`CREATE TEMPORARY VIEW a AS SELECT b`},
{`CREATE MATERIALIZED VIEW a AS SELECT * FROM b`},
{`CREATE MATERIALIZED VIEW IF NOT EXISTS a AS SELECT * FROM b`},
{`REFRESH MATERIALIZED VIEW a.b`},
{`REFRESH MATERIALIZED VIEW CONCURRENTLY a.b`},
{`REFRESH MATERIALIZED VIEW a.b WITH DATA`},
{`REFRESH MATERIALIZED VIEW a.b WITH NO DATA`},
{`CREATE SEQUENCE a`},
{`EXPLAIN CREATE SEQUENCE a`},
{`CREATE SEQUENCE IF NOT EXISTS a`},
{`CREATE SEQUENCE a CYCLE`},
{`CREATE SEQUENCE a NO CYCLE`},
{`CREATE SEQUENCE a CACHE 0`},
{`CREATE SEQUENCE a CACHE 1`},
{`CREATE SEQUENCE a CACHE 2`},
{`CREATE SEQUENCE a INCREMENT 5`},
{`CREATE SEQUENCE a INCREMENT BY 5`},
{`CREATE SEQUENCE a NO MAXVALUE`},
{`CREATE SEQUENCE a MAXVALUE 1000`},
{`CREATE SEQUENCE a NO MINVALUE`},
{`CREATE SEQUENCE a MINVALUE 1000`},
{`CREATE SEQUENCE a START 1000`},
{`CREATE SEQUENCE a START WITH 1000`},
{`CREATE SEQUENCE a INCREMENT 5 NO MAXVALUE MINVALUE 1 START 3`},
{`CREATE SEQUENCE a INCREMENT 5 NO CYCLE NO MAXVALUE MINVALUE 1 START 3 CACHE 1`},
{`CREATE SEQUENCE a VIRTUAL`},
{`CREATE TEMPORARY SEQUENCE a`},
{`CREATE SEQUENCE a OWNED BY b`},
{`CREATE SEQUENCE a OWNED BY NONE`},
{`CREATE SEQUENCE a AS int`},
{`CREATE EXTENSION bob`},
{`CREATE EXTENSION IF NOT EXISTS bob`},
{`CREATE STATISTICS a ON col1 FROM t`},
{`EXPLAIN CREATE STATISTICS a ON col1 FROM t`},
{`CREATE STATISTICS a FROM t`},
{`CREATE STATISTICS a FROM [53]`},
{`CREATE STATISTICS a ON col1, col2 FROM t`},
{`CREATE STATISTICS a ON col1 FROM d.t`},
{`CREATE STATISTICS a ON col1 FROM t`},
{`CREATE STATISTICS a ON col1 FROM t WITH OPTIONS THROTTLING 0.9`},
{`CREATE STATISTICS a ON col1 FROM t WITH OPTIONS AS OF SYSTEM TIME '2016-01-01'`},
{`CREATE STATISTICS a ON col1 FROM t WITH OPTIONS THROTTLING 0.1 AS OF SYSTEM TIME '2016-01-01'`},
{`ANALYZE t`},
{`ANALYZE db.sc.t`},
{`CREATE TYPE a AS ENUM ()`},
{`CREATE TYPE a AS ENUM ('a')`},
{`CREATE TYPE a AS ENUM ('a', 'b', 'c')`},
{`CREATE TYPE a.b AS ENUM ('a', 'b', 'c')`},
{`CREATE TYPE a.b.c AS ENUM ('a', 'b', 'c')`},
{`DROP SCHEMA a`},
{`DROP SCHEMA a, b`},
{`DROP SCHEMA IF EXISTS a, b, c`},
{`DROP SCHEMA IF EXISTS a, b CASCADE`},
{`DROP SCHEMA IF EXISTS a, b RESTRICT`},
{`DROP SCHEMA a RESTRICT`},
{`DROP SCHEMA a.a`},
{`DROP SCHEMA a.a, b.b, c.c`},
{`DROP SCHEMA a, b.b, c`},
{`DROP SCHEMA IF EXISTS a.a, b.b, c.c`},
{`DROP SCHEMA IF EXISTS a, b, c.c`},
{`DROP SCHEMA IF EXISTS a.a, b.b CASCADE`},
{`DROP SCHEMA IF EXISTS a.a, b CASCADE`},
{`DROP SCHEMA IF EXISTS a.a, b.c RESTRICT`},
{`DROP SCHEMA IF EXISTS a, b.b RESTRICT`},
{`DROP SCHEMA a.a RESTRICT`},
{`DROP TYPE a`},
{`DROP TYPE a, b, c`},
{`DROP TYPE db.sc.a, sc.a`},
{`DROP TYPE IF EXISTS db.sc.a, sc.a`},
{`DROP TYPE db.sc.a, sc.a CASCADE`},
{`DROP TYPE IF EXISTS db.sc.a, sc.a CASCADE`},
{`DROP TYPE IF EXISTS db.sc.a, sc.a RESTRICT`},
{`DELETE FROM a`},
{`EXPLAIN DELETE FROM a`},
{`DELETE FROM a.b`},
{`DELETE FROM a.b@c`},
{`DELETE FROM a WHERE a = b`},
{`DELETE FROM a WHERE a = b LIMIT c`},
{`DELETE FROM a WHERE a = b ORDER BY c`},
{`DELETE FROM a WHERE a = b ORDER BY c LIMIT d`},
{`DELETE FROM a WHERE a = b RETURNING a, b`},
{`DELETE FROM a WHERE a = b RETURNING 1, 2`},
{`DELETE FROM a WHERE a = b RETURNING a + b`},
{`DELETE FROM a WHERE a = b RETURNING NOTHING`},
{`DELETE FROM a WHERE a = b ORDER BY c LIMIT d RETURNING e`},
{`DISCARD ALL`},
{`DROP DATABASE a`},
{`EXPLAIN DROP DATABASE a`},
{`DROP DATABASE IF EXISTS a`},
{`DROP DATABASE a CASCADE`},
{`DROP DATABASE a RESTRICT`},
{`DROP TABLE a`},
{`EXPLAIN DROP TABLE a`},
{`DROP TABLE a.b`},
{`DROP TABLE a, b`},
{`DROP TABLE IF EXISTS a`},
{`DROP TABLE a RESTRICT`},
{`DROP TABLE a.b RESTRICT`},
{`DROP TABLE a, b RESTRICT`},
{`DROP TABLE IF EXISTS a RESTRICT`},
{`DROP TABLE a CASCADE`},
{`DROP TABLE a.b CASCADE`},
{`DROP TABLE a, b CASCADE`},
{`DROP TABLE IF EXISTS a CASCADE`},
{`DROP INDEX a.b@c`},
{`DROP INDEX a`},
{`DROP INDEX a.b`},
{`DROP INDEX IF EXISTS a.b@c`},
{`DROP INDEX a.b@c, d@f`},
{`DROP INDEX IF EXISTS a.b@c, d@f`},
{`DROP INDEX a.b@c CASCADE`},
{`DROP INDEX IF EXISTS a.b@c RESTRICT`},
{`DROP VIEW a`},
{`DROP VIEW a.b`},
{`DROP VIEW a, b`},
{`DROP VIEW IF EXISTS a`},
{`DROP VIEW a RESTRICT`},
{`DROP VIEW IF EXISTS a, b RESTRICT`},
{`DROP VIEW a.b CASCADE`},
{`DROP VIEW a, b CASCADE`},
{`DROP MATERIALIZED VIEW a, b`},
{`DROP MATERIALIZED VIEW IF EXISTS a`},
{`DROP SEQUENCE a`},
{`EXPLAIN DROP SEQUENCE a`},
{`DROP SEQUENCE a.b`},
{`DROP SEQUENCE a, b`},
{`DROP SEQUENCE IF EXISTS a`},
{`DROP SEQUENCE a RESTRICT`},
{`DROP SEQUENCE IF EXISTS a, b RESTRICT`},
{`DROP SEQUENCE a.b CASCADE`},
{`DROP SEQUENCE a, b CASCADE`},
{`CANCEL JOBS SELECT a`},
{`EXPLAIN CANCEL JOBS SELECT a`},
{`CANCEL QUERIES SELECT a`},
{`EXPLAIN CANCEL QUERIES SELECT a`},
{`CANCEL SESSIONS SELECT a`},
{`EXPLAIN CANCEL SESSIONS SELECT a`},
{`CANCEL QUERIES IF EXISTS SELECT a`},
{`CANCEL SESSIONS IF EXISTS SELECT a`},
{`RESUME JOBS SELECT a`},
{`EXPLAIN RESUME JOBS SELECT a`},
{`PAUSE JOBS SELECT a`},
{`EXPLAIN PAUSE JOBS SELECT a`},
{`PAUSE SCHEDULES SELECT a`},
{`EXPLAIN PAUSE SCHEDULES SELECT a`},
{`RESUME SCHEDULES SELECT a`},
{`EXPLAIN RESUME SCHEDULES SELECT a`},
{`DROP SCHEDULES SELECT a`},
{`EXPLAIN DROP SCHEDULES SELECT a`},
{`SHOW JOBS SELECT a`},
{`EXPLAIN SHOW JOBS SELECT a`},
{`SHOW JOBS WHEN COMPLETE SELECT a`},
{`EXPLAIN SHOW JOBS WHEN COMPLETE SELECT a`},
{`PAUSE JOBS FOR SCHEDULES SELECT 1`},
{`EXPLAIN PAUSE JOBS FOR SCHEDULES SELECT 1`},
{`RESUME JOBS FOR SCHEDULES SELECT unnest(ARRAY[1, 2, 3])`},
{`EXPLAIN RESUME JOBS FOR SCHEDULES SELECT unnest(ARRAY[1, 2, 3])`},
{`CANCEL JOBS FOR SCHEDULES (SELECT schedule_id FROM somewhere WHERE something = true)`},
{`EXPLAIN CANCEL JOBS FOR SCHEDULES (SELECT schedule_id FROM somewhere WHERE something = true)`},
{`SHOW JOBS FOR SCHEDULES SELECT 123`},
{`EXPLAIN SHOW JOBS FOR SCHEDULES SELECT 123`},
{`SHOW SCHEDULE 123`},
{`EXPLAIN SHOW SCHEDULE 123`},
{`SHOW SCHEDULES`},
{`EXPLAIN SHOW SCHEDULES`},
{`SHOW SCHEDULES FOR BACKUP`},
{`EXPLAIN SHOW SCHEDULES FOR BACKUP`},
{`SHOW PAUSED SCHEDULES`},
{`EXPLAIN SHOW PAUSED SCHEDULES`},
{`SHOW RUNNING SCHEDULES`},
{`EXPLAIN SHOW RUNNING SCHEDULES`},
{`SHOW PAUSED SCHEDULES FOR BACKUP`},
{`EXPLAIN SHOW PAUSED SCHEDULES FOR BACKUP`},
{`SHOW RUNNING SCHEDULES FOR BACKUP`},
{`EXPLAIN SHOW RUNNING SCHEDULES FOR BACKUP`},
{`EXPLAIN SELECT 1`},
{`EXPLAIN EXPLAIN SELECT 1`},
{`EXPLAIN (OPT, VERBOSE) SELECT 1`},
{`EXPLAIN ANALYZE (DISTSQL) SELECT 1`},
{`EXPLAIN ANALYZE (DEBUG) SELECT 1`},
{`EXPLAIN ANALYZE SELECT 1`},
{`SELECT * FROM [EXPLAIN SELECT 1]`},
{`SELECT * FROM [SHOW TRANSACTION STATUS]`},
{`SHOW barfoo`},
{`EXPLAIN SHOW barfoo`},
{`SHOW database`},
{`SHOW timezone`},
{`SHOW "BLAH"`},
{`SHOW CLUSTER SETTING a`},
{`EXPLAIN SHOW CLUSTER SETTING a`},
{`SHOW ALL CLUSTER SETTINGS`},
{`SHOW PUBLIC CLUSTER SETTINGS`},
{`SHOW DATABASES`},
{`EXPLAIN SHOW DATABASES`},
{`SHOW ENUMS`},
{`EXPLAIN SHOW ENUMS`},
{`SHOW TYPES`},
{`EXPLAIN SHOW TYPES`},
{`SHOW SCHEMAS`},
{`EXPLAIN SHOW SCHEMAS`},
{`SHOW SCHEMAS FROM a`},
{`SHOW SEQUENCES`},
{`EXPLAIN SHOW SEQUENCES`},
{`SHOW SEQUENCES FROM a`},
{`SHOW TABLES`},
{`SHOW TABLES WITH COMMENT`},
{`EXPLAIN SHOW TABLES`},
{`SHOW TABLES FROM a`},
{`SHOW TABLES FROM a WITH COMMENT`},
{`SHOW TABLES FROM a.b`},
{`SHOW TABLES FROM a.b WITH COMMENT`},
{`SHOW COLUMNS FROM a`},
{`EXPLAIN SHOW COLUMNS FROM a`},
{`SHOW COLUMNS FROM a.b.c`},
{`SHOW INDEXES FROM a`},
{`EXPLAIN SHOW INDEXES FROM a`},
{`SHOW INDEXES FROM a WITH COMMENT`},
{`EXPLAIN SHOW INDEXES FROM a WITH COMMENT`},
{`SHOW INDEXES FROM a.b.c`},
{`SHOW INDEXES FROM a.b.c WITH COMMENT`},
{`SHOW INDEXES FROM DATABASE a`},
{`SHOW INDEXES FROM DATABASE a WITH COMMENT`},
{`SHOW CONSTRAINTS FROM a`},
{`SHOW CONSTRAINTS FROM a.b.c`},
{`EXPLAIN SHOW CONSTRAINTS FROM a.b.c`},
{`SHOW TABLES FROM a.b; SHOW COLUMNS FROM b`},
{`EXPLAIN SHOW TABLES FROM a`},
{`SHOW ROLES`},
{`EXPLAIN SHOW ROLES`},
{`SHOW USERS`},
{`EXPLAIN SHOW USERS`},
{`SHOW JOBS`},
{`EXPLAIN SHOW JOBS`},
{`SHOW AUTOMATIC JOBS`},
{`EXPLAIN SHOW AUTOMATIC JOBS`},
{`SHOW CLUSTER QUERIES`},
{`EXPLAIN SHOW CLUSTER QUERIES`},
{`SHOW ALL CLUSTER QUERIES`},
{`EXPLAIN SHOW ALL CLUSTER QUERIES`},
{`SHOW LOCAL QUERIES`},
{`EXPLAIN SHOW LOCAL QUERIES`},
{`SHOW ALL LOCAL QUERIES`},
{`EXPLAIN SHOW ALL LOCAL QUERIES`},
{`SHOW CLUSTER SESSIONS`},
{`EXPLAIN SHOW CLUSTER SESSIONS`},
{`SHOW ALL CLUSTER SESSIONS`},
{`EXPLAIN SHOW ALL CLUSTER SESSIONS`},
{`SHOW LOCAL SESSIONS`},
{`EXPLAIN SHOW LOCAL SESSIONS`},
{`SHOW ALL LOCAL SESSIONS`},
{`EXPLAIN SHOW ALL LOCAL SESSIONS`},
{`SHOW TRACE FOR SESSION`},
{`EXPLAIN SHOW TRACE FOR SESSION`},
{`SHOW KV TRACE FOR SESSION`},
{`EXPLAIN SHOW KV TRACE FOR SESSION`},
{`SHOW EXPERIMENTAL_REPLICA TRACE FOR SESSION`},
{`EXPLAIN SHOW EXPERIMENTAL_REPLICA TRACE FOR SESSION`},
{`SHOW STATISTICS FOR TABLE t`},
{`SHOW STATISTICS USING JSON FOR TABLE t`},
{`EXPLAIN SHOW STATISTICS FOR TABLE t`},
{`SHOW STATISTICS FOR TABLE d.t`},
{`SHOW HISTOGRAM 123`},
{`EXPLAIN SHOW HISTOGRAM 123`},
{`SHOW RANGE FROM TABLE t FOR ROW (1, 2)`},
{`SHOW RANGE FROM TABLE d.t FOR ROW (1, 2)`},
{`SHOW RANGE FROM INDEX d.t@i FOR ROW (1, 2)`},
{`SHOW RANGE FROM INDEX t@i FOR ROW (1, 2)`},
{`SHOW RANGE FROM INDEX i FOR ROW (1, 2)`},
{`SHOW RANGES FROM TABLE d.t`},
{`EXPLAIN SHOW RANGES FROM TABLE d.t`},
{`SHOW RANGES FROM TABLE t`},
{`SHOW RANGES FROM INDEX d.t@i`},
{`SHOW RANGES FROM INDEX t@i`},
{`SHOW RANGES FROM INDEX d.i`},
{`SHOW RANGES FROM INDEX i`},
{`SHOW REGIONS FROM CLUSTER`},
{`SHOW REGIONS FROM ALL DATABASES`},
{`SHOW REGIONS FROM DATABASE`},
{`SHOW REGIONS FROM DATABASE d`},
{`SHOW SURVIVAL GOAL FROM DATABASE`},
{`SHOW SURVIVAL GOAL FROM DATABASE d`},
{`SHOW EXPERIMENTAL_FINGERPRINTS FROM TABLE d.t`},
{`SHOW ZONE CONFIGURATIONS`},
{`EXPLAIN SHOW ZONE CONFIGURATIONS`},
{`SHOW ZONE CONFIGURATION FOR RANGE default`},
{`SHOW ZONE CONFIGURATION FOR RANGE meta`},
{`SHOW ZONE CONFIGURATION FOR DATABASE db`},
{`SHOW ZONE CONFIGURATION FOR TABLE db.t`},
{`SHOW ZONE CONFIGURATION FOR TABLE db.schema.t`},
{`SHOW ZONE CONFIGURATION FOR PARTITION p OF TABLE db.t`},
{`SHOW ZONE CONFIGURATION FOR TABLE t`},
{`SHOW ZONE CONFIGURATION FOR PARTITION p OF TABLE t`},
{`SHOW ZONE CONFIGURATION FOR INDEX db.t@i`},
{`SHOW ZONE CONFIGURATION FOR INDEX t@i`},
{`SHOW ZONE CONFIGURATION FOR INDEX i`},
// Tables are the default, but can also be specified with
// GRANT x ON TABLE y. However, the stringer does not output TABLE.
{`SHOW GRANTS`},
{`EXPLAIN SHOW GRANTS`},
{`SHOW GRANTS ON TABLE foo`},
{`SHOW GRANTS ON SCHEMA foo`},
{`SHOW GRANTS ON SCHEMA foo.bar`},
{`SHOW GRANTS ON SCHEMA foo, bar`},
{`SHOW GRANTS ON SCHEMA foo.bar, bar.baz`},
{`SHOW GRANTS ON TYPE typ1`},
{`SHOW GRANTS ON TYPE typ1, schema2.typ2, db.schema.typ`},
{`SHOW GRANTS ON TABLE foo, db.foo`},
{`SHOW GRANTS ON TYPE foo`},
{`SHOW GRANTS ON TYPE foo, bar`},
{`SHOW GRANTS ON TYPE foo, bar FOR baz`},
{`SHOW GRANTS ON DATABASE foo, bar`},
{`SHOW GRANTS ON DATABASE foo FOR bar`},
{`SHOW GRANTS FOR bar, baz`},
{`SHOW GRANTS ON ROLE`},
{`SHOW GRANTS ON ROLE foo`},
{`SHOW GRANTS ON ROLE foo, bar`},
{`SHOW GRANTS ON ROLE foo FOR bar`},
{`SHOW GRANTS ON ROLE FOR bar, baz`},
{`SHOW TRANSACTION STATUS`},
{`EXPLAIN SHOW TRANSACTION STATUS`},
{`SHOW SAVEPOINT STATUS`},
{`EXPLAIN SHOW SAVEPOINT STATUS`},
{`SHOW LAST QUERY STATISTICS`},
{`SHOW SYNTAX 'select 1'`},
{`EXPLAIN SHOW SYNTAX 'select 1'`},
{`PREPARE a AS SELECT 1`},
{`PREPARE a AS EXPLAIN SELECT 1`},
{`PREPARE a (INT8) AS SELECT $1`},
{`PREPARE a (STRING, STRING) AS SELECT $1, $2`},
{`PREPARE a AS INSERT INTO a VALUES (1)`},
{`PREPARE a (INT8) AS INSERT INTO a VALUES ($1)`},
{`PREPARE a AS UPDATE a SET b = 1`},
{`PREPARE a (INT8) AS UPDATE a SET b = $1`},
{`PREPARE a AS UPSERT INTO a VALUES (1)`},
{`PREPARE a (INT8) AS UPSERT INTO a VALUES ($1)`},
{`PREPARE a AS DELETE FROM a`},
{`PREPARE a (INT8) AS DELETE FROM a WHERE b = $1`},
{`PREPARE a AS BACKUP DATABASE a TO 'b'`},
{`PREPARE a (STRING) AS BACKUP DATABASE a TO $1`},
{`PREPARE a AS RESTORE DATABASE a FROM 'b'`},
{`PREPARE a (STRING) AS RESTORE DATABASE a FROM $1`},
{`PREPARE a AS CANCEL QUERIES SELECT 1`},
{`PREPARE a (STRING) AS CANCEL QUERIES SELECT $1`},
{`PREPARE a AS CANCEL QUERIES IF EXISTS SELECT 1`},
{`PREPARE a (STRING) AS CANCEL QUERIES IF EXISTS SELECT $1`},
{`PREPARE a AS CANCEL SESSIONS SELECT 1`},
{`PREPARE a (STRING) AS CANCEL SESSIONS SELECT $1`},
{`PREPARE a AS CANCEL SESSIONS IF EXISTS SELECT 1`},
{`PREPARE a (STRING) AS CANCEL SESSIONS IF EXISTS SELECT $1`},
{`PREPARE a AS CANCEL JOBS SELECT 1`},
{`PREPARE a (INT8) AS CANCEL JOBS SELECT $1`},
{`PREPARE a AS PAUSE JOBS SELECT 1`},
{`PREPARE a (INT8) AS PAUSE JOBS SELECT $1`},
{`PREPARE a AS RESUME JOBS SELECT 1`},
{`PREPARE a (INT8) AS RESUME JOBS SELECT $1`},
{`PREPARE a AS IMPORT TABLE a CREATE USING 'b' CSV DATA ('c') WITH temp = 'd'`},
{`PREPARE a (STRING, STRING, STRING) AS IMPORT TABLE a CREATE USING $1 CSV DATA ($2) WITH temp = $3`},
{`PREPARE a AS OPT PLAN 'some-string'`},
{`PREPARE a (STRING, INT8) AS OPT PLAN 'some-string'`},
{`EXECUTE a`},
{`EXECUTE a DISCARD ROWS`},
{`EXECUTE a (1)`},
{`EXECUTE a (1, 1)`},
{`EXECUTE a (1, 1) DISCARD ROWS`},
{`EXECUTE a (1 + 1)`},
{`DEALLOCATE a`},
{`DEALLOCATE ALL`},
// Tables are the default, but can also be specified with
// GRANT x ON TABLE y. However, the stringer does not output TABLE.
{`GRANT SELECT ON TABLE foo TO root`},
{`GRANT SELECT, DELETE, UPDATE ON TABLE foo, db.foo TO root, bar`},
{`GRANT DROP ON DATABASE foo TO root`},
{`GRANT ALL ON DATABASE foo TO root, test`},
{`GRANT SELECT, INSERT ON DATABASE bar TO foo, bar, baz`},
{`GRANT SELECT, INSERT ON DATABASE db1, db2 TO foo, bar, baz`},
{`GRANT SELECT, INSERT ON DATABASE db1, db2 TO "test-user"`},
{`GRANT rolea, roleb TO usera, userb`},
{`GRANT rolea, roleb TO usera, userb WITH ADMIN OPTION`},
// GRANT ON TYPE.
{`GRANT USAGE ON TYPE foo TO root`},
{`GRANT USAGE, GRANT ON TYPE foo TO root`},
{`GRANT ALL ON TYPE foo TO root`},
// GRANT ON SCHEMA.
{`GRANT USAGE ON SCHEMA foo TO root`},
{`GRANT USAGE ON SCHEMA foo.bar TO root`},
{`GRANT USAGE, GRANT, CREATE ON SCHEMA foo TO root`},
{`GRANT USAGE, GRANT, CREATE ON SCHEMA foo.bar TO root`},
{`GRANT ALL ON SCHEMA foo, bar, baz TO root`},
{`GRANT ALL ON SCHEMA a.b, c.d, e.f TO root`},
// Tables are the default, but can also be specified with
// REVOKE x ON TABLE y. However, the stringer does not output TABLE.
{`REVOKE SELECT ON TABLE foo FROM root`},
{`REVOKE UPDATE, DELETE ON TABLE foo, db.foo FROM root, bar`},
{`REVOKE INSERT ON DATABASE foo FROM root`},
{`REVOKE ALL ON DATABASE foo FROM root, test`},
{`REVOKE SELECT, INSERT ON DATABASE bar FROM foo, bar, baz`},
{`REVOKE SELECT, INSERT ON DATABASE db1, db2 FROM foo, bar, baz`},
{`REVOKE rolea, roleb FROM usera, userb`},
{`REVOKE ADMIN OPTION FOR rolea, roleb FROM usera, userb`},
// REVOKE ON TYPE.
{`REVOKE USAGE ON TYPE foo FROM root`},
{`REVOKE USAGE, GRANT ON TYPE foo FROM root`},
{`REVOKE ALL ON TYPE foo FROM root`},
// REVOKE ON SCHEMA.
{`REVOKE USAGE ON SCHEMA foo FROM root`},
{`REVOKE USAGE ON SCHEMA foo.bar FROM root`},
{`REVOKE USAGE, GRANT, CREATE ON SCHEMA foo FROM root`},
{`REVOKE USAGE, GRANT, CREATE ON SCHEMA foo.bar FROM root`},
{`REVOKE ALL ON SCHEMA foo, bar, baz FROM root`},
{`REVOKE ALL ON SCHEMA a.b, c.d, e.f FROM root`},
{`INSERT INTO a VALUES (1)`},
{`EXPLAIN INSERT INTO a VALUES (1)`},
{`INSERT INTO a.b VALUES (1)`},
{`INSERT INTO a VALUES (1, 2)`},
{`INSERT INTO a VALUES (1, DEFAULT)`},
{`INSERT INTO a VALUES (1, 2), (3, 4)`},
{`INSERT INTO a VALUES (a + 1, 2 * 3)`},
{`INSERT INTO a(a, b) VALUES (1, 2)`},
{`INSERT INTO a SELECT b, c FROM d`},
{`INSERT INTO a DEFAULT VALUES`},
{`INSERT INTO a VALUES (1) RETURNING a, b`},
{`INSERT INTO a VALUES (1, 2) RETURNING 1, 2`},
{`INSERT INTO a VALUES (1, 2) RETURNING a + b, c`},
{`INSERT INTO a VALUES (1, 2) RETURNING NOTHING`},
{`UPSERT INTO a VALUES (1)`},
{`EXPLAIN UPSERT INTO a VALUES (1)`},
{`UPSERT INTO a.b VALUES (1)`},
{`UPSERT INTO a VALUES (1, 2)`},
{`UPSERT INTO a VALUES (1, DEFAULT)`},
{`UPSERT INTO a VALUES (1, 2), (3, 4)`},
{`UPSERT INTO a VALUES (a + 1, 2 * 3)`},
{`UPSERT INTO a(a, b) VALUES (1, 2)`},
{`UPSERT INTO a SELECT b, c FROM d`},
{`UPSERT INTO a DEFAULT VALUES`},
{`UPSERT INTO a DEFAULT VALUES RETURNING a, b`},
{`UPSERT INTO a DEFAULT VALUES RETURNING 1, 2`},
{`UPSERT INTO a DEFAULT VALUES RETURNING a + b`},
{`UPSERT INTO a DEFAULT VALUES RETURNING NOTHING`},
{`INSERT INTO a VALUES (1) ON CONFLICT DO NOTHING`},
{`INSERT INTO a VALUES (1) ON CONFLICT (a) DO NOTHING`},
{`INSERT INTO a VALUES (1) ON CONFLICT (a) WHERE b > 0 DO NOTHING`},
{`INSERT INTO a VALUES (1) ON CONFLICT (a) DO UPDATE SET a = 1`},
{`INSERT INTO a VALUES (1) ON CONFLICT (a) WHERE b > 0 DO UPDATE SET a = 1`},
{`INSERT INTO a VALUES (1) ON CONFLICT (a, b) DO UPDATE SET a = 1`},
{`INSERT INTO a VALUES (1) ON CONFLICT (a) DO UPDATE SET a = 1, b = excluded.a`},
{`INSERT INTO a VALUES (1) ON CONFLICT (a) DO UPDATE SET a = 1 WHERE b > 2`},
{`INSERT INTO a VALUES (1) ON CONFLICT (a) DO UPDATE SET a = DEFAULT`},
{`INSERT INTO a VALUES (1) ON CONFLICT (a) DO UPDATE SET (a, b) = (SELECT 1, 2)`},
{`INSERT INTO a VALUES (1) ON CONFLICT (a) DO UPDATE SET (a, b) = (SELECT 1, 2) RETURNING a, b`},
{`INSERT INTO a VALUES (1) ON CONFLICT (a) DO UPDATE SET (a, b) = (SELECT 1, 2) RETURNING 1, 2`},
{`INSERT INTO a VALUES (1) ON CONFLICT (a) DO UPDATE SET (a, b) = (SELECT 1, 2) RETURNING a + b`},
{`INSERT INTO a VALUES (1) ON CONFLICT (a) DO UPDATE SET (a, b) = (SELECT 1, 2) RETURNING NOTHING`},
{`SELECT 1 + 1`},
{`SELECT -1`},
{`SELECT .1`},
{`SELECT 1.2e1`},
{`SELECT 1.2e+1`},
{`SELECT 1.2e-1`},
{`SELECT true AND false`},
{`SELECT true AND NULL`},
{`SELECT true = false`},
{`SELECT (true = false)`},
{`SELECT (ARRAY['a', 'b'])[2]`},
{`SELECT (ARRAY (VALUES (1), (2)))[1]`},
{`SELECT (SELECT 1)`},
{`SELECT ((SELECT 1))`},
{`SELECT (SELECT ARRAY['a', 'b'])[2]`},
{`SELECT ((SELECT ARRAY['a', 'b']))[2]`},
{`SELECT ((((VALUES (1)))))`},
{`SELECT EXISTS (SELECT 1)`},
{`SELECT (VALUES (1))`},
{`SELECT (1, 2, 3)`},
{`SELECT ((1, 2, 3) AS a, b, c)`},
{`SELECT ((1, 2, 3))`},
{`SELECT ((1, 2, 3) AS a, b, c)`},
{`SELECT (((1, 2, 3) AS a, b, c)).a`},
{`SELECT (((1, 2, 3) AS a, b, c)).*`},
{`SELECT ()`},
{`SELECT (() AS a)`},
{`SELECT ((() AS a)).a`},
{`SELECT ((() AS a)).*`},
{`SELECT ((() AS a)).@1`},
{`SELECT (TABLE a)`},
{`SELECT 0x1`},
{`SELECT 'Deutsch' COLLATE de`},
{`SELECT a @> b`},
{`SELECT a <@ b`},
{`SELECT a ? b`},
{`SELECT a ?| b`},
{`SELECT a ?& b`},
{`SELECT a->'x'`},
{`SELECT a#>'{x}'`},
{`SELECT a#>>'{x}'`},
{`SELECT (a->'x')->'y'`},
{`SELECT (a->'x')->>'y'`},
{`SELECT b && c`},
{`SELECT |/a`},
{`SELECT ||/a`},
{`SELECT 1 FROM t`},
{`SELECT 1, 2 FROM t`},
{`SELECT * FROM t`},
{`SELECT "*" FROM t`},
{`SELECT a, b FROM t`},
{`SELECT a AS b FROM t`},
{`SELECT a.* FROM t`},
{`SELECT a = b FROM t`},
{`SELECT $1 FROM t`},
{`SELECT $1, $2 FROM t`},
{`SELECT NULL FROM t`},
{`SELECT 0.1 FROM t`},
{`SELECT a FROM t`},
{`SELECT a.b FROM t`},
{`SELECT a.b.* FROM t`},
{`SELECT a.b[1] FROM t`},
{`SELECT a.b[1 + 1:4][3] FROM t`},
{`SELECT a.b[:4][3] FROM t`},
{`SELECT a.b[1 + 1:][3] FROM t`},
{`SELECT a.b[:][3] FROM t`},
{`SELECT 'a' FROM t`},
{`SELECT 'a' FROM t@bar`},
{`SELECT 'a' FROM t@primary`},
{`SELECT 'a' FROM t@like`},
{`SELECT 'a' FROM t@{NO_INDEX_JOIN}`},
{`SELECT 'a' FROM t@{IGNORE_FOREIGN_KEYS}`},
{`SELECT 'a' FROM t@{FORCE_INDEX=idx,ASC}`},
{`SELECT 'a' FROM t@{FORCE_INDEX=idx,DESC,IGNORE_FOREIGN_KEYS}`},
{`SELECT * FROM t AS "of" AS OF SYSTEM TIME '2016-01-01'`},
{`SELECT BOOL 'foo', 'foo'::BOOL`},
{`SELECT BIT '10', '10'::BIT`},
{`SELECT VARBIT '1', '1'::VARBIT`},
{`SELECT INT2 'foo', 'foo'::INT2`},
{`SELECT INT4 'foo', 'foo'::INT4`},
{`SELECT INT8 'foo', 'foo'::INT8`},
{`SELECT FLOAT4 'foo', 'foo'::FLOAT4`},
{`SELECT DECIMAL 'foo', 'foo'::DECIMAL`},
{`SELECT CHAR 'foo', 'foo'::CHAR`},
{`SELECT VARCHAR 'foo', 'foo'::VARCHAR`},
{`SELECT STRING 'foo', 'foo'::STRING`},
{`SELECT BYTES 'foo', 'foo'::BYTES`},
{`SELECT DATE 'foo', 'foo'::DATE`},
{`SELECT TIME 'foo', 'foo'::TIME`},
{`SELECT TIMESTAMP 'foo', 'foo'::TIMESTAMP`},
{`SELECT TIMESTAMPTZ 'foo', 'foo'::TIMESTAMPTZ`},
{`SELECT JSONB 'foo', 'foo'::JSONB`},
{`SELECT 'foo'::DECIMAL(1)`},
{`SELECT 'foo'::DECIMAL(2,1)`},
{`SELECT 'foo'::BIT(3)`},
{`SELECT 'foo'::VARBIT(3)`},
{`SELECT 'foo'::CHAR(3)`},
{`SELECT 'foo'::VARCHAR(3)`},
{`SELECT 'foo'::STRING(3)`},
{`SELECT 'foo'::TIMESTAMP(6)`},
{`SELECT 'foo'::TIMESTAMPTZ(6)`},
{`SELECT 'foo'::TIME(6)`},
{`SELECT '0'::INTERVAL`},
{`SELECT 'foo'::BOX2D`},
{`SELECT 'foo'::GEOGRAPHY`},
{`SELECT 'foo'::GEOGRAPHY(POINT,4326)`},
{`SELECT 'foo'::GEOGRAPHY(POINT)`},
{`SELECT 'foo'::GEOMETRY`},
{`SELECT 'foo'::GEOMETRY(POINT)`},
{`SELECT 'foo'::GEOMETRY(POINT,4326)`},
{`SELECT '192.168.0.1'::INET`},
{`SELECT '192.168.0.1':::INET`},
{`SELECT INET '192.168.0.1'`},
{`SELECT 1:::REGTYPE`},
{`SELECT 1:::REGPROC`},
{`SELECT 1:::REGPROCEDURE`},
{`SELECT 1:::REGCLASS`},
{`SELECT 1:::REGNAMESPACE`},
{`SELECT 'a' AS "12345"`},
{`SELECT 'a' AS clnm`},
{`SELECT 'a' AS primary`},
{`SELECT 'a' AS like`},
{`SELECT 0xf0 FROM t`},
{`SELECT 0xF0 FROM t`},
// Test various cases of qualified and not statically known types.
{`SELECT 1::notatype`},
{`SELECT 1::schem.typ`},
{`SELECT 1::int4.typ`},
{`SELECT 1::db.schem.typ`},
{`SELECT 1::db.int4.typ[]`},
{`CREATE TABLE t (x special.type)`},
{`CREATE TABLE t (x int4.type)`},
{`CREATE TABLE t (x notatype)`},
{`SELECT 1 IS OF (my.type, int4.type)`},
{`SELECT my.type ''`},
{`SELECT int4.type ''`},
{`SELECT foo ''`},
{`SELECT CAST(1.2 + 2.3 AS notatype)`},
{`SELECT ANNOTATE_TYPE(1.2 + 2.3, notatype)`},
{`SELECT 'f'::blah`},