diff --git a/pkg/ccl/backupccl/backup_test.go b/pkg/ccl/backupccl/backup_test.go index dd07c45892ea..e1b53c5ed81c 100644 --- a/pkg/ccl/backupccl/backup_test.go +++ b/pkg/ccl/backupccl/backup_test.go @@ -1152,7 +1152,7 @@ func TestBackupRestoreSystemJobs(t *testing.T) { if err := jobutils.VerifySystemJob(t, sqlDB, 0, jobspb.TypeRestore, jobs.StatusSucceeded, jobs.Record{ Username: security.RootUserName(), Description: fmt.Sprintf( - `RESTORE TABLE bank FROM '%s', '%s' WITH into_db='restoredb'`, + `RESTORE TABLE bank FROM '%s', '%s' WITH into_db = 'restoredb'`, sanitizedFullDir+"redacted", sanitizedIncDir+"redacted", ), DescriptorIDs: descpb.IDs{ @@ -1207,16 +1207,19 @@ func TestEncryptedBackupRestoreSystemJobs(t *testing.T) { } { t.Run(tc.name, func(t *testing.T) { var encryptionOption string - var sanitizedEncryptionOption string + var sanitizedEncryptionOption1 string + var sanitizedEncryptionOption2 string if tc.useKMS { correctKMSURI, _ := getAWSKMSURI(t, regionEnvVariable, keyIDEnvVariable) - encryptionOption = fmt.Sprintf("kms='%s'", correctKMSURI) + encryptionOption = fmt.Sprintf("kms = '%s'", correctKMSURI) sanitizedURI, err := redactTestKMSURI(correctKMSURI) require.NoError(t, err) - sanitizedEncryptionOption = fmt.Sprintf("kms='%s'", sanitizedURI) + sanitizedEncryptionOption1 = fmt.Sprintf("kms = '%s'", sanitizedURI) + sanitizedEncryptionOption2 = sanitizedEncryptionOption1 } else { - encryptionOption = "encryption_passphrase='abcdefg'" - sanitizedEncryptionOption = "encryption_passphrase='redacted'" + encryptionOption = "encryption_passphrase = 'abcdefg'" + sanitizedEncryptionOption1 = "encryption_passphrase = '*****'" + sanitizedEncryptionOption2 = "encryption_passphrase = 'redacted'" } _, _, sqlDB, _, cleanupFn := BackupRestoreTestSetup(t, MultiNode, 3, InitManualReplication) conn := sqlDB.DB.(*gosql.DB) @@ -1238,7 +1241,7 @@ func TestEncryptedBackupRestoreSystemJobs(t *testing.T) { Username: security.RootUserName(), Description: fmt.Sprintf( `BACKUP DATABASE data TO '%s' WITH %s`, - backupLoc1, sanitizedEncryptionOption), + backupLoc1, sanitizedEncryptionOption1), DescriptorIDs: descpb.IDs{ descpb.ID(backupDatabaseID), descpb.ID(backupTableID), @@ -1255,8 +1258,8 @@ into_db='restoredb', %s)`, encryptionOption), backupLoc1) if err := jobutils.VerifySystemJob(t, sqlDB, 0, jobspb.TypeRestore, jobs.StatusSucceeded, jobs.Record{ Username: security.RootUserName(), Description: fmt.Sprintf( - `RESTORE TABLE data.bank FROM '%s' WITH %s, into_db='restoredb'`, - backupLoc1, sanitizedEncryptionOption, + `RESTORE TABLE data.bank FROM '%s' WITH %s, into_db = 'restoredb'`, + backupLoc1, sanitizedEncryptionOption2, ), DescriptorIDs: descpb.IDs{ descpb.ID(restoreDatabaseID + 1), @@ -4278,8 +4281,8 @@ func TestEncryptedBackup(t *testing.T) { encryptionOption = fmt.Sprintf("kms='%s'", correctKMSURI) incorrectEncryptionOption = fmt.Sprintf("kms='%s'", incorrectKeyARNURI) } else { - encryptionOption = "encryption_passphrase='abcdefg'" - incorrectEncryptionOption = "encryption_passphrase='wrongpassphrase'" + encryptionOption = "encryption_passphrase = 'abcdefg'" + incorrectEncryptionOption = "encryption_passphrase = 'wrongpassphrase'" } ctx, _, sqlDB, rawDir, cleanupFn := BackupRestoreTestSetup(t, MultiNode, 3, InitManualReplication) defer cleanupFn() @@ -5531,7 +5534,7 @@ func TestBackupRestoreShowJob(t *testing.T) { t, "SELECT description FROM [SHOW JOBS] WHERE description != 'updating privileges' ORDER BY description", [][]string{ {"BACKUP DATABASE data TO 'nodelocal://0/foo' WITH revision_history"}, - {"RESTORE TABLE data.bank FROM 'nodelocal://0/foo' WITH into_db='data 2', skip_missing_foreign_keys"}, + {"RESTORE TABLE data.bank FROM 'nodelocal://0/foo' WITH into_db = 'data 2', skip_missing_foreign_keys"}, }, ) } @@ -7597,10 +7600,10 @@ func TestManifestBitFlip(t *testing.T) { }) t.Run("encrypted", func(t *testing.T) { - sqlDB.Exec(t, `BACKUP DATABASE data TO 'nodelocal://0/bit_flip_encrypted' WITH encryption_passphrase='abc'`) + sqlDB.Exec(t, `BACKUP DATABASE data TO 'nodelocal://0/bit_flip_encrypted' WITH encryption_passphrase = 'abc'`) flipBitInManifests(t, rawDir) sqlDB.ExpectErr(t, checksumError, - `RESTORE data.* FROM 'nodelocal://0/bit_flip_encrypted' WITH encryption_passphrase='abc', into_db='r3'`) + `RESTORE data.* FROM 'nodelocal://0/bit_flip_encrypted' WITH encryption_passphrase = 'abc', into_db = 'r3'`) }) } diff --git a/pkg/ccl/backupccl/create_scheduled_backup.go b/pkg/ccl/backupccl/create_scheduled_backup.go index 22ee814b6a9c..c47336ac0213 100644 --- a/pkg/ccl/backupccl/create_scheduled_backup.go +++ b/pkg/ccl/backupccl/create_scheduled_backup.go @@ -457,7 +457,10 @@ func makeBackupSchedule( // We do not set backupNode.AsOf: this is done when the scheduler kicks off the backup. // Serialize backup statement and set schedule executor and its args. - args.BackupStatement = tree.AsString(backupNode) + // + // TODO(bulkio): this serialization is erroneous, see issue + // https://github.com/cockroachdb/cockroach/issues/63216 + args.BackupStatement = tree.AsStringWithFlags(backupNode, tree.FmtSimple|tree.FmtShowPasswords) any, err := pbtypes.MarshalAny(args) if err != nil { return nil, err diff --git a/pkg/ccl/backupccl/create_scheduled_backup_test.go b/pkg/ccl/backupccl/create_scheduled_backup_test.go index 75282b39ccbd..4c28f7bdf515 100644 --- a/pkg/ccl/backupccl/create_scheduled_backup_test.go +++ b/pkg/ccl/backupccl/create_scheduled_backup_test.go @@ -304,7 +304,7 @@ func TestSerializesScheduledBackupExecutionArgs(t *testing.T) { }, { name: "enterprise-license-required-for-encryption", - query: "CREATE SCHEDULE FOR BACKUP INTO 'nodelocal://0/backup' WITH encryption_passphrase='secret' RECURRING '@hourly'", + query: "CREATE SCHEDULE FOR BACKUP INTO 'nodelocal://0/backup' WITH encryption_passphrase = 'secret' RECURRING '@hourly'", user: freeUser, errMsg: "use of BACKUP with encryption requires an enterprise license", }, @@ -333,12 +333,12 @@ func TestSerializesScheduledBackupExecutionArgs(t *testing.T) { user: enterpriseUser, query: ` CREATE SCHEDULE FOR BACKUP TABLE system.jobs, system.scheduled_jobs INTO 'nodelocal://0/backup' - WITH encryption_passphrase='secret' RECURRING '@weekly'`, + WITH encryption_passphrase = 'secret' RECURRING '@weekly'`, expectedSchedules: []expectedSchedule{ { nameRe: "BACKUP .*", - backupStmt: "BACKUP TABLE system.jobs, system.scheduled_jobs INTO 'nodelocal://0/backup' WITH encryption_passphrase='secret', detached", - shownStmt: "BACKUP TABLE system.jobs, system.scheduled_jobs INTO 'nodelocal://0/backup' WITH encryption_passphrase='redacted', detached", + backupStmt: "BACKUP TABLE system.jobs, system.scheduled_jobs INTO 'nodelocal://0/backup' WITH encryption_passphrase = 'secret', detached", + shownStmt: "BACKUP TABLE system.jobs, system.scheduled_jobs INTO 'nodelocal://0/backup' WITH encryption_passphrase = '*****', detached", period: 7 * 24 * time.Hour, }, }, diff --git a/pkg/sql/opt/exec/execbuilder/scalar.go b/pkg/sql/opt/exec/execbuilder/scalar.go index 86f310fe9195..b7d27a52a629 100644 --- a/pkg/sql/opt/exec/execbuilder/scalar.go +++ b/pkg/sql/opt/exec/execbuilder/scalar.go @@ -376,7 +376,7 @@ func (b *Builder) buildColumnAccess( if childTyp.TupleLabels() != nil { lbl = childTyp.TupleLabels()[colIdx] } - return tree.NewTypedColumnAccessExpr(input, lbl, colIdx), nil + return tree.NewTypedColumnAccessExpr(input, tree.Name(lbl), colIdx), nil } func (b *Builder) buildArray(ctx *buildScalarCtx, scalar opt.ScalarExpr) (tree.TypedExpr, error) { diff --git a/pkg/sql/opt/optbuilder/util.go b/pkg/sql/opt/optbuilder/util.go index ac633d69f192..3ab75b418db2 100644 --- a/pkg/sql/opt/optbuilder/util.go +++ b/pkg/sql/opt/optbuilder/util.go @@ -101,7 +101,7 @@ func (b *Builder) expandStar( } // NewTypedColumnAccessExpr expects colName to be empty if the tuple // should be accessed by index. - exprs[i] = tree.NewTypedColumnAccessExpr(texpr, colName, i) + exprs[i] = tree.NewTypedColumnAccessExpr(texpr, tree.Name(colName), i) } } for i := len(aliases); i < len(typ.TupleContents()); i++ { diff --git a/pkg/sql/parser/parse_test.go b/pkg/sql/parser/parse_test.go index 304eef703619..7116ed700576 100644 --- a/pkg/sql/parser/parse_test.go +++ b/pkg/sql/parser/parse_test.go @@ -11,10 +11,10 @@ package parser_test import ( + "bytes" "fmt" "go/constant" "reflect" - "regexp" "strings" "testing" @@ -30,2864 +30,63 @@ import ( "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 syntax 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))`}, - {`CREATE TABLE a (b INT8 NOT VISIBLE)`}, - {`CREATE TABLE a (b INT8 NULL NOT VISIBLE)`}, - {`CREATE TABLE a (b INT8 CONSTRAINT c NOT NULL NOT VISIBLE)`}, - // "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 NOTHING`}, - {`CREATE TABLE a (b INT8) PARTITION ALL BY NOTHING`}, - {`CREATE TABLE a (b INT8) PARTITION BY LIST (b) (PARTITION p1 VALUES IN (1, DEFAULT), PARTITION p2 VALUES IN ((1, 2), (3, 4)))`}, - {`CREATE TABLE a (b INT8) PARTITION ALL 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 (INVERTED 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 INVERTED 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 TABLE a PARTITION ALL 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 TABLE a (a INT4) LOCALITY REGIONAL BY ROW AS bobby`}, - - {`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 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 IF NOT EXISTS 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 (DISTSQL) SELECT 1`}, - {`EXPLAIN (DISTSQL, JSON) 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 STATEMENTS`}, - {`EXPLAIN SHOW CLUSTER STATEMENTS`}, - {`SHOW ALL CLUSTER STATEMENTS`}, - {`EXPLAIN SHOW ALL CLUSTER STATEMENTS`}, - {`SHOW LOCAL STATEMENTS`}, - {`EXPLAIN SHOW LOCAL STATEMENTS`}, - {`SHOW ALL LOCAL STATEMENTS`}, - {`EXPLAIN SHOW ALL LOCAL STATEMENTS`}, - {`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`}, - {`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 FROM RANGE default`}, - {`SHOW ZONE CONFIGURATION FROM RANGE meta`}, - {`SHOW ZONE CONFIGURATION FROM DATABASE db`}, - {`SHOW ZONE CONFIGURATION FROM TABLE db.t`}, - {`SHOW ZONE CONFIGURATION FROM TABLE db.schema.t`}, - {`SHOW ZONE CONFIGURATION FROM PARTITION p OF TABLE db.t`}, - {`SHOW ZONE CONFIGURATION FROM TABLE t`}, - {`SHOW ZONE CONFIGURATION FROM PARTITION p OF TABLE t`}, - {`SHOW ZONE CONFIGURATION FROM INDEX db.t@i`}, - {`SHOW ZONE CONFIGURATION FROM INDEX t@i`}, - {`SHOW ZONE CONFIGURATION FROM 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`}, - - // Escaping may change since the scanning process loses information - // (you can write e'\'' or ''''), but these are the idempotent cases. - // Generally, anything that needs to escape plus \ and ' leads to an - // escaped string. - {`SELECT e'a\'a' FROM t`}, - {`SELECT e'a\\\\na' FROM t`}, - {`SELECT e'\\\\n' FROM t`}, - {`SELECT "a""a" FROM t`}, - {`SELECT a FROM "t\n"`}, // no escaping in sql identifiers - {`SELECT a FROM "t"""`}, // no escaping in sql identifiers - {`SELECT "full" FROM t`}, // must quote column name keyword - - {`SELECT "FROM" FROM t`}, - {`SELECT CAST(1 AS STRING)`}, - {`SELECT ANNOTATE_TYPE(1, STRING)`}, - {`SELECT a FROM t AS bar`}, - {`SELECT a FROM t AS bar (bar1)`}, - {`SELECT a FROM t AS bar (bar1, bar2, bar3)`}, - {`SELECT a FROM t WITH ORDINALITY`}, - {`SELECT a FROM t WITH ORDINALITY AS bar`}, - {`SELECT a FROM (SELECT 1 FROM t)`}, - {`SELECT a FROM (SELECT 1 FROM t) AS bar`}, - {`SELECT a FROM (SELECT 1 FROM t) AS bar (bar1)`}, - {`SELECT a FROM (SELECT 1 FROM t) AS bar (bar1, bar2, bar3)`}, - {`SELECT a FROM (SELECT 1 FROM t) WITH ORDINALITY`}, - {`SELECT a FROM (SELECT 1 FROM t) WITH ORDINALITY AS bar`}, - {`SELECT a FROM ROWS FROM (a(x), b(y), c(z))`}, - {`SELECT a FROM t1, t2`}, - {`SELECT a FROM t1, LATERAL (SELECT * FROM t2 WHERE a = b)`}, - {`SELECT a FROM t1, LATERAL ROWS FROM (generate_series(1, t1.x))`}, - {`SELECT a FROM t AS t1`}, - {`SELECT a FROM t AS t1 (c1)`}, - {`SELECT a FROM t AS t1 (c1, c2, c3, c4)`}, - {`SELECT a FROM s.t`}, - - {`SELECT count(DISTINCT a) FROM t`}, - {`SELECT count(ALL a) FROM t`}, - - {`SELECT a FROM t WHERE a = b`}, - {`SELECT a FROM t WHERE NOT (a = b)`}, - {`SELECT a FROM t WHERE EXISTS (SELECT 1 FROM t)`}, - {`SELECT a FROM t WHERE NOT true`}, - {`SELECT a FROM t WHERE NOT false`}, - {`SELECT a FROM t WHERE a IN (b,)`}, - {`SELECT a FROM t WHERE a IN (b, c)`}, - {`SELECT a FROM t WHERE a IN (SELECT a FROM t)`}, - {`SELECT a FROM t WHERE a NOT IN (b, c)`}, - {`SELECT a FROM t WHERE a = ANY (ARRAY[b, c])`}, - {`SELECT a FROM t WHERE a = ANY ARRAY[b, c]`}, - {`SELECT a FROM t WHERE a != SOME (ARRAY[b, c])`}, - {`SELECT a FROM t WHERE a != SOME ARRAY[b, c]`}, - {`SELECT a FROM t WHERE a = ANY (SELECT 1)`}, - {`SELECT a FROM t WHERE a LIKE ALL (ARRAY[b, c])`}, - {`SELECT a FROM t WHERE a LIKE ALL ARRAY[b, c]`}, - {`SELECT a FROM t WHERE a LIKE b`}, - {`SELECT a FROM t WHERE a NOT LIKE b`}, - {`SELECT a FROM t WHERE a ILIKE b`}, - {`SELECT a FROM t WHERE a NOT ILIKE b`}, - {`SELECT a FROM t WHERE a SIMILAR TO b`}, - {`SELECT a FROM t WHERE a NOT SIMILAR TO b`}, - {`SELECT a FROM t WHERE a ~ b`}, - {`SELECT a FROM t WHERE a !~ b`}, - {`SELECT a FROM t WHERE a ~* c`}, - {`SELECT a FROM t WHERE a !~* c`}, - {`SELECT a FROM t WHERE a BETWEEN b AND c`}, - {`SELECT a FROM t WHERE a BETWEEN SYMMETRIC b AND c`}, - {`SELECT a FROM t WHERE a NOT BETWEEN b AND c`}, - {`SELECT a FROM t WHERE a NOT BETWEEN SYMMETRIC b AND c`}, - {`SELECT a FROM t WHERE a IS NULL`}, - {`SELECT a FROM t WHERE a IS NOT NULL`}, - {`SELECT a FROM t WHERE (a, b) IS NULL`}, - {`SELECT a FROM t WHERE (a, b) IS NOT NULL`}, - {`SELECT a FROM t WHERE a IS true`}, - {`SELECT a FROM t WHERE a IS NOT true`}, - {`SELECT a FROM t WHERE a IS false`}, - {`SELECT a FROM t WHERE a IS NOT false`}, - {`SELECT a FROM t WHERE a IS OF (INT8)`}, - {`SELECT a FROM t WHERE a IS NOT OF (FLOAT8, STRING)`}, - {`SELECT a FROM t WHERE a IS DISTINCT FROM b`}, - {`SELECT a FROM t WHERE a IS NOT DISTINCT FROM b`}, - {`SELECT a FROM t WHERE (a, b) IS NOT DISTINCT FROM NULL`}, - {`SELECT a FROM t WHERE (a, b) IS DISTINCT FROM NULL`}, - {`SELECT a FROM t WHERE a < b`}, - {`SELECT a FROM t WHERE a <= b`}, - {`SELECT a FROM t WHERE a >= b`}, - {`SELECT a FROM t WHERE a != b`}, - {`SELECT a FROM t WHERE a = (SELECT a FROM t)`}, - {`SELECT a FROM t WHERE a = (b)`}, - {`SELECT a FROM t WHERE CASE WHEN a = b THEN c END`}, - {`SELECT a FROM t WHERE CASE WHEN a = b THEN c ELSE d END`}, - {`SELECT a FROM t WHERE CASE WHEN a = b THEN c WHEN b = d THEN d ELSE d END`}, - {`SELECT a FROM t WHERE CASE aa WHEN a = b THEN c END`}, - {`SELECT a FROM t WHERE a = b()`}, - {`SELECT a FROM t WHERE a = b(c)`}, - {`SELECT a FROM t WHERE a = b(c, d)`}, - {`SELECT a FROM t WHERE a = count(*)`}, - {`SELECT a FROM t WHERE a = IF(b, c, d)`}, - {`SELECT a FROM t WHERE a = IFERROR(b, c, d)`}, - {`SELECT a FROM t WHERE a = IFERROR(b, c)`}, - {`SELECT a FROM t WHERE a = ISERROR(b)`}, - {`SELECT a FROM t WHERE a = ISERROR(b, c)`}, - {`SELECT a FROM t WHERE a = IFNULL(b, c)`}, - {`SELECT a FROM t WHERE a = NULLIF(b, c)`}, - {`SELECT a FROM t WHERE a = COALESCE(a, b, c, d, e)`}, - {`SELECT (a.b) FROM t WHERE (b.c) = 2`}, - - {`SELECT a FROM t ORDER BY a`}, - {`SELECT a FROM t ORDER BY a ASC`}, - {`SELECT a FROM t ORDER BY a DESC`}, - {`SELECT a FROM t ORDER BY PRIMARY KEY t`}, - {`SELECT a FROM t ORDER BY PRIMARY KEY t ASC`}, - {`SELECT a FROM t ORDER BY PRIMARY KEY t DESC`}, - {`SELECT a FROM t ORDER BY INDEX t@foo`}, - {`SELECT a FROM t ORDER BY INDEX t@foo ASC`}, - {`SELECT a FROM t ORDER BY INDEX t@foo DESC`}, - {`SELECT a FROM t ORDER BY INDEX t@primary`}, - {`SELECT a FROM t ORDER BY INDEX t@like`}, - {`SELECT a FROM t ORDER BY a NULLS FIRST`}, - {`SELECT a FROM t ORDER BY a ASC NULLS FIRST`}, - {`SELECT a FROM t ORDER BY a DESC NULLS LAST`}, - - {`SELECT 1 FROM t GROUP BY a`}, - {`SELECT 1 FROM t GROUP BY a, b`}, - {`SELECT 1 FROM t GROUP BY ()`}, - {`SELECT sum(x ORDER BY y) FROM t`}, - {`SELECT sum(x ORDER BY y, z) FROM t`}, - - {`SELECT a FROM t HAVING a = b`}, - - {`SELECT a FROM t WINDOW w AS ()`}, - {`SELECT a FROM t WINDOW w AS (w2)`}, - {`SELECT a FROM t WINDOW w AS (PARTITION BY b)`}, - {`SELECT a FROM t WINDOW w AS (PARTITION BY b, 1 + 2)`}, - {`SELECT a FROM t WINDOW w AS (ORDER BY c)`}, - {`SELECT a FROM t WINDOW w AS (ORDER BY c, 1 + 2)`}, - {`SELECT a FROM t WINDOW w AS (PARTITION BY b ORDER BY c)`}, - - {`SELECT avg(1) OVER w FROM t`}, - {`SELECT avg(1) OVER () FROM t`}, - {`SELECT avg(1) OVER (w) FROM t`}, - {`SELECT avg(1) OVER (PARTITION BY b) FROM t`}, - {`SELECT avg(1) OVER (ORDER BY c) FROM t`}, - {`SELECT avg(1) OVER (PARTITION BY b ORDER BY c) FROM t`}, - {`SELECT avg(1) OVER (w PARTITION BY b ORDER BY c) FROM t`}, - - {`SELECT avg(1) OVER (ROWS UNBOUNDED PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (ROWS 1 PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (ROWS CURRENT ROW) FROM t`}, - {`SELECT avg(1) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t`}, - {`SELECT avg(1) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) FROM t`}, - {`SELECT avg(1) OVER (ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (ROWS BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t`}, - {`SELECT avg(1) OVER (ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (ROWS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (w ROWS UNBOUNDED PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (PARTITION BY b ROWS UNBOUNDED PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (ORDER BY c ROWS UNBOUNDED PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (PARTITION BY b ORDER BY c ROWS UNBOUNDED PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (w PARTITION BY b ORDER BY c ROWS UNBOUNDED PRECEDING) FROM t`}, - - {`SELECT avg(1) OVER (RANGE UNBOUNDED PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (RANGE 1 PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (RANGE CURRENT ROW) FROM t`}, - {`SELECT avg(1) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t`}, - {`SELECT avg(1) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (RANGE BETWEEN 1 PRECEDING AND 1 PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (RANGE BETWEEN 1 PRECEDING AND CURRENT ROW) FROM t`}, - {`SELECT avg(1) OVER (RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (RANGE BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t`}, - {`SELECT avg(1) OVER (RANGE BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (RANGE BETWEEN 1 FOLLOWING AND 1 FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (RANGE BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (w RANGE UNBOUNDED PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (PARTITION BY b RANGE UNBOUNDED PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (ORDER BY c RANGE UNBOUNDED PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (PARTITION BY b ORDER BY c RANGE UNBOUNDED PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (w PARTITION BY b ORDER BY c RANGE UNBOUNDED PRECEDING) FROM t`}, - - {`SELECT avg(1) OVER (GROUPS UNBOUNDED PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (GROUPS 1 PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (GROUPS CURRENT ROW) FROM t`}, - {`SELECT avg(1) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t`}, - {`SELECT avg(1) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (GROUPS BETWEEN 1 PRECEDING AND 1 PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (GROUPS BETWEEN 1 PRECEDING AND CURRENT ROW) FROM t`}, - {`SELECT avg(1) OVER (GROUPS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (GROUPS BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (GROUPS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t`}, - {`SELECT avg(1) OVER (GROUPS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (GROUPS BETWEEN 1 FOLLOWING AND 1 FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (GROUPS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t`}, - {`SELECT avg(1) OVER (w GROUPS UNBOUNDED PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (PARTITION BY b GROUPS UNBOUNDED PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (ORDER BY c GROUPS UNBOUNDED PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (PARTITION BY b ORDER BY c GROUPS UNBOUNDED PRECEDING) FROM t`}, - {`SELECT avg(1) OVER (w PARTITION BY b ORDER BY c GROUPS UNBOUNDED PRECEDING) FROM t`}, - - {`SELECT avg(1) OVER (ROWS UNBOUNDED PRECEDING EXCLUDE CURRENT ROW) FROM t`}, - {`SELECT avg(1) OVER (ROWS UNBOUNDED PRECEDING EXCLUDE GROUP) FROM t`}, - {`SELECT avg(1) OVER (ROWS UNBOUNDED PRECEDING EXCLUDE TIES) FROM t`}, - - {`SELECT percentile_disc(0.50) WITHIN GROUP (ORDER BY c) FROM t`}, - {`SELECT percentile_disc(0.50) WITHIN GROUP (ORDER BY c DESC) FROM t`}, - {`SELECT percentile_cont(0.50) WITHIN GROUP (ORDER BY c) FROM t`}, - {`SELECT percentile_disc(ARRAY[0.95, 0.90]) WITHIN GROUP (ORDER BY c) FROM t`}, - {`SELECT percentile_cont(ARRAY[0.95, 0.90]) WITHIN GROUP (ORDER BY c) FROM t`}, - - {`SELECT avg(1) FILTER (WHERE a > b)`}, - {`SELECT avg(1) FILTER (WHERE a > b) OVER (ORDER BY c)`}, - - {`SELECT a FROM t UNION SELECT 1 FROM t`}, - {`SELECT a FROM t UNION SELECT 1 FROM t UNION SELECT 1 FROM t`}, - {`SELECT a FROM t UNION ALL SELECT 1 FROM t`}, - {`SELECT a FROM t EXCEPT SELECT 1 FROM t`}, - {`SELECT a FROM t EXCEPT ALL SELECT 1 FROM t`}, - {`SELECT a FROM t INTERSECT SELECT 1 FROM t`}, - {`SELECT a FROM t INTERSECT ALL SELECT 1 FROM t`}, - - {`SELECT a FROM t1 JOIN t2 ON a = b`}, - {`SELECT a FROM t1 JOIN t2 USING (a)`}, - {`SELECT a FROM t1 INNER MERGE JOIN t2 USING (a)`}, - {`SELECT a FROM t1 LEFT JOIN t2 ON a = b`}, - {`SELECT a FROM t1 LEFT LOOKUP JOIN t2 ON a = b`}, - {`SELECT a FROM t1 LEFT INVERTED JOIN t2 ON a @> b`}, - {`SELECT a FROM t1 RIGHT JOIN t2 ON a = b`}, - {`SELECT a FROM t1 INNER JOIN t2 ON a = b`}, - {`SELECT a FROM t1 INNER HASH JOIN t2 ON a = b`}, - {`SELECT a FROM t1 CROSS JOIN t2`}, - {`SELECT a FROM t1 CROSS LOOKUP JOIN t2`}, - {`SELECT a FROM t1 CROSS INVERTED JOIN t2`}, - {`SELECT a FROM t1 NATURAL JOIN t2`}, - {`SELECT a FROM t1 NATURAL INNER MERGE JOIN t2`}, - {`SELECT a FROM t1 INNER JOIN t2 USING (a)`}, - {`SELECT a FROM t1 FULL JOIN t2 USING (a)`}, - {`SELECT a FROM t1 FULL MERGE JOIN t2 USING (a)`}, - {`SELECT * FROM (t1 WITH ORDINALITY AS o1 CROSS JOIN t2 WITH ORDINALITY AS o2) WITH ORDINALITY AS o3`}, - - {`SELECT a FROM t1 AS OF SYSTEM TIME '2016-01-01'`}, - {`SELECT a FROM t1, t2 AS OF SYSTEM TIME '2016-01-01'`}, - {`SELECT a FROM t1 AS OF SYSTEM TIME -('a' || 'b')::INTERVAL`}, - - {`SELECT * FROM t LIMIT ALL`}, - {`SELECT EXISTS ((((TABLE error FOR KEY SHARE)) LIMIT ALL FOR KEY SHARE)) AS is FROM ident`}, - - {`SELECT a FROM t LIMIT a`}, - {`SELECT a FROM t OFFSET b`}, - {`SELECT a FROM t LIMIT a OFFSET b`}, - {`SELECT DISTINCT * FROM t`}, - {`SELECT DISTINCT a, b FROM t`}, - {`SELECT DISTINCT ON (a, b) c FROM t`}, - - {`SET a = 3`}, - {`EXPLAIN SET a = 3`}, - {`SET a = 3, 4`}, - {`SET a = '3'`}, - {`SET a = 3.0`}, - {`SET a = $1`}, - {`SET a = off`}, - {`SET TRANSACTION READ ONLY`}, - {`SET TRANSACTION READ WRITE`}, - {`SET TRANSACTION ISOLATION LEVEL SERIALIZABLE`}, - {`SET TRANSACTION PRIORITY LOW`}, - {`SET TRANSACTION PRIORITY NORMAL`}, - {`SET TRANSACTION PRIORITY HIGH`}, - {`SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH`}, - {`SET TRANSACTION DEFERRABLE`}, - {`SET TRANSACTION NOT DEFERRABLE`}, - {`SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH, AS OF SYSTEM TIME '-1s', NOT DEFERRABLE`}, - - {`SET TRACING = off`}, - {`EXPLAIN SET TRACING = off`}, - {`SET TRACING = 'cluster', 'kv'`}, - - {`SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE`}, - - {`SET CLUSTER SETTING a = 3`}, - {`EXPLAIN SET CLUSTER SETTING a = 3`}, - {`SET CLUSTER SETTING a = '3s'`}, - {`SET CLUSTER SETTING a = '3'`}, - {`SET CLUSTER SETTING a = 3.0`}, - {`SET CLUSTER SETTING a = $1`}, - {`SET CLUSTER SETTING a = off`}, - - {`SELECT * FROM (VALUES (1, 2)) AS foo`}, - {`SELECT * FROM (VALUES (1, 2)) AS foo (a, b)`}, - - {`SELECT * FROM [123 AS t]`}, - {`SELECT * FROM [123(1, 2, 3) AS t]`}, - {`SELECT * FROM [123() AS t]`}, - {`SELECT * FROM t@[123]`}, - {`SELECT * FROM [123 AS t]@[456]`}, - - {`INSERT INTO [123 AS t] VALUES (1)`}, - {`INSERT INTO [123(1, 2) AS t] VALUES (1, 2)`}, - {`INSERT INTO [123 AS t](col1, col2) VALUES (1, 2)`}, - {`UPSERT INTO [123 AS t] VALUES (1)`}, - {`UPDATE [123 AS t] SET b = 3`}, - {`UPDATE [123 AS t]@idx SET b = 3`}, - {`DELETE FROM [123 AS t]`}, - {`DELETE FROM [123 AS t]@idx`}, - - {`SELECT (1 + 2).*`}, - {`SELECT (1 + 2).@1`}, - {`SELECT (1 + 2).col`}, - {`SELECT (abc.def).col`}, - {`SELECT (i.keys).col`}, - {`SELECT (i.keys).*`}, - {`SELECT (i.keys).@1`}, - {`SELECT (ARRAY['a', 'b', 'c']).name`}, - - {`SELECT 1 FOR UPDATE`}, - {`SELECT 1 FOR NO KEY UPDATE`}, - {`SELECT 1 FOR SHARE`}, - {`SELECT 1 FOR KEY SHARE`}, - {`SELECT 1 FOR UPDATE OF a`}, - {`SELECT 1 FOR NO KEY UPDATE OF a, b`}, - {`SELECT 1 FOR UPDATE SKIP LOCKED`}, - {`SELECT 1 FOR NO KEY UPDATE OF a, b NOWAIT`}, - {`SELECT 1 ORDER BY 1 FOR UPDATE`}, - {`SELECT 1 LIMIT 1 FOR UPDATE`}, - {`SELECT 1 ORDER BY 1 LIMIT 1 FOR UPDATE`}, - {`SELECT 1 FOR UPDATE FOR UPDATE`}, - {`SELECT 1 FOR SHARE OF a FOR KEY SHARE SKIP LOCKED`}, - - {`TABLE a`}, // Shorthand for: SELECT * FROM a; used e.g. in CREATE VIEW v AS TABLE t - {`EXPLAIN TABLE a`}, - {`TABLE [123 AS a]`}, - - {`TRUNCATE TABLE a`}, - {`EXPLAIN TRUNCATE TABLE a`}, - {`TRUNCATE TABLE a, b.c`}, - {`TRUNCATE TABLE a CASCADE`}, - - {`UPDATE a SET b = 3`}, - {`EXPLAIN UPDATE a SET b = 3`}, - {`UPDATE a.b SET b = 3`}, - {`UPDATE a.b@c SET b = 3`}, - {`UPDATE a SET b = 3, c = DEFAULT`}, - {`UPDATE a SET b = 3, c = DEFAULT FROM b`}, - {`UPDATE a SET b = 3, c = DEFAULT FROM a AS other`}, - {`UPDATE a SET b = 3, c = DEFAULT FROM a AS other, b`}, - {`UPDATE a SET b = 3 + 4`}, - {`UPDATE a SET (b, c) = (3, DEFAULT)`}, - {`UPDATE a SET (b, c) = (SELECT 3, 4)`}, - {`UPDATE a SET b = 3 WHERE a = b`}, - {`UPDATE a SET b = 3 WHERE a = b LIMIT c`}, - {`UPDATE a SET b = 3 WHERE a = b ORDER BY c`}, - {`UPDATE a SET b = 3 WHERE a = b ORDER BY c LIMIT d`}, - {`UPDATE a SET b = 3 WHERE a = b RETURNING a`}, - {`UPDATE a SET b = 3 WHERE a = b RETURNING 1, 2`}, - {`UPDATE a SET b = 3 WHERE a = b RETURNING a, a + b`}, - {`UPDATE a SET b = 3 WHERE a = b RETURNING NOTHING`}, - {`UPDATE a SET b = 3 WHERE a = b ORDER BY c LIMIT d RETURNING e`}, - {`UPDATE a SET b = 3 FROM other WHERE a = b ORDER BY c LIMIT d RETURNING e`}, - - {`UPDATE t AS "0" SET k = ''`}, // "0" lost its quotes - {`SELECT * FROM "0" JOIN "0" USING (id, "0")`}, // last "0" lost its quotes. - - {`ALTER DATABASE a RENAME TO b`}, - {`ALTER DATABASE a ADD REGION "us-west-1"`}, - {`ALTER DATABASE a DROP REGION "us-west-1"`}, - {`ALTER DATABASE a SURVIVE REGION FAILURE`}, - {`ALTER DATABASE a PRIMARY REGION "us-west-3"`}, - {`EXPLAIN ALTER DATABASE a RENAME TO b`}, - - {`ALTER DATABASE a OWNER TO foo`}, - - {`ALTER INDEX b RENAME TO b`}, - {`EXPLAIN ALTER INDEX b RENAME TO b`}, - {`ALTER INDEX a@b RENAME TO b`}, - {`ALTER INDEX a@primary RENAME TO like`}, - {`ALTER INDEX IF EXISTS b RENAME TO b`}, - {`ALTER INDEX IF EXISTS a@b RENAME TO b`}, - {`ALTER INDEX IF EXISTS a@primary RENAME TO like`}, - - {`ALTER SCHEMA s RENAME TO s2`}, - {`ALTER SCHEMA s OWNER TO foo`}, - {`ALTER SCHEMA db.s RENAME TO s2`}, - {`ALTER SCHEMA db.s OWNER TO foo`}, - - {`ALTER TABLE a RENAME TO b`}, - {`EXPLAIN ALTER TABLE a RENAME TO b`}, - {`ALTER TABLE IF EXISTS a RENAME TO b`}, - {`ALTER TABLE a RENAME COLUMN c1 TO c2`}, - {`ALTER TABLE IF EXISTS a RENAME COLUMN c1 TO c2`}, - {`ALTER TABLE a RENAME CONSTRAINT c1 TO c2`}, - {`ALTER TABLE IF EXISTS a RENAME CONSTRAINT c1 TO c2`}, - {`ALTER TABLE a RENAME CONSTRAINT c TO d, RENAME COLUMN e TO f`}, - {`ALTER TABLE a SET LOCALITY GLOBAL`}, - {`ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN region_name`}, - {`ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION`}, - {`ALTER TABLE a SET LOCALITY REGIONAL BY ROW`}, - - {`ALTER TABLE a ADD COLUMN b INT8, ADD CONSTRAINT a_idx UNIQUE (a)`}, - {`EXPLAIN ALTER TABLE a ADD COLUMN b INT8`}, - {`ALTER TABLE a ADD COLUMN IF NOT EXISTS b INT8, ADD CONSTRAINT a_idx UNIQUE (a)`}, - {`ALTER TABLE IF EXISTS a ADD COLUMN b INT8, ADD CONSTRAINT a_idx UNIQUE (a)`}, - {`ALTER TABLE IF EXISTS a ADD COLUMN IF NOT EXISTS b INT8, ADD CONSTRAINT a_idx UNIQUE (a)`}, - {`ALTER TABLE a ADD COLUMN b INT8 UNIQUE WITHOUT INDEX, ADD CONSTRAINT a_no_idx UNIQUE WITHOUT INDEX (a)`}, - {`ALTER TABLE a ADD COLUMN IF NOT EXISTS b INT8, ADD CONSTRAINT a_idx UNIQUE (a) NOT VALID`}, - {`ALTER TABLE IF EXISTS a ADD COLUMN b INT8, ADD CONSTRAINT a_idx UNIQUE (a)`}, - {`ALTER TABLE IF EXISTS a ADD COLUMN IF NOT EXISTS b INT8, ADD CONSTRAINT a_idx UNIQUE (a)`}, - {`ALTER TABLE a ADD COLUMN b INT8 FAMILY fam_a`}, - {`ALTER TABLE a ADD COLUMN b INT8 CREATE FAMILY`}, - {`ALTER TABLE a ADD COLUMN b INT8 CREATE FAMILY fam_b`}, - {`ALTER TABLE a ADD COLUMN b INT8 CREATE IF NOT EXISTS FAMILY fam_b`}, - - {`ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a, b, c)`}, - - {`ALTER TABLE a DROP COLUMN b, DROP CONSTRAINT a_idx`}, - {`ALTER TABLE a DROP COLUMN IF EXISTS b, DROP CONSTRAINT a_idx`}, - {`ALTER TABLE IF EXISTS a DROP COLUMN b, DROP CONSTRAINT a_idx`}, - {`ALTER TABLE IF EXISTS a DROP COLUMN IF EXISTS b, DROP CONSTRAINT a_idx`}, - {`ALTER TABLE a DROP COLUMN b, DROP CONSTRAINT a_idx`}, - {`ALTER TABLE a DROP COLUMN IF EXISTS b, DROP CONSTRAINT a_idx`}, - {`ALTER TABLE IF EXISTS a DROP COLUMN b, DROP CONSTRAINT a_idx`}, - {`ALTER TABLE IF EXISTS a DROP COLUMN IF EXISTS b, DROP CONSTRAINT a_idx`}, - {`ALTER TABLE a DROP COLUMN b CASCADE`}, - {`ALTER TABLE a DROP COLUMN b RESTRICT`}, - {`ALTER TABLE a DROP CONSTRAINT b CASCADE`}, - {`ALTER TABLE a DROP CONSTRAINT IF EXISTS b RESTRICT`}, - {`ALTER TABLE a VALIDATE CONSTRAINT a`}, - {`ALTER TABLE a ADD PRIMARY KEY (x, y, z)`}, - {`ALTER TABLE a ADD PRIMARY KEY (x, y, z) USING HASH WITH BUCKET_COUNT = 10 INTERLEAVE IN PARENT b (x, y)`}, - {`ALTER TABLE a ADD CONSTRAINT "primary" PRIMARY KEY (x, y, z)`}, - {`ALTER TABLE a ADD CONSTRAINT "primary" PRIMARY KEY (x, y, z) USING HASH WITH BUCKET_COUNT = 10 INTERLEAVE IN PARENT b (x, y)`}, - - {`ALTER TABLE a ALTER COLUMN b SET DEFAULT 42`}, - {`ALTER TABLE a ALTER COLUMN b SET DEFAULT NULL`}, - {`ALTER TABLE a ALTER COLUMN b DROP DEFAULT`}, - {`ALTER TABLE a ALTER COLUMN b DROP NOT NULL`}, - {`ALTER TABLE a ALTER COLUMN b DROP STORED`}, - - {`ALTER TABLE a ALTER COLUMN b SET DATA TYPE INT8`}, - {`ALTER TABLE a ALTER COLUMN b SET DATA TYPE STRING COLLATE en USING b::STRING`}, - {`ALTER TABLE a ALTER COLUMN b SET DATA TYPE DECIMAL(10)[]`}, - - {`ALTER TABLE a SET SCHEMA s`}, - {`ALTER TABLE IF EXISTS a SET SCHEMA s`}, - - {`ALTER TABLE a OWNER TO foo`}, - {`ALTER TABLE IF EXISTS a OWNER TO foo`}, - - {`ALTER VIEW v SET SCHEMA s`}, - {`ALTER VIEW IF EXISTS a SET SCHEMA s`}, - {`ALTER MATERIALIZED VIEW v SET SCHEMA s`}, - {`ALTER MATERIALIZED VIEW IF EXISTS a SET SCHEMA s`}, - - {`ALTER VIEW v RENAME TO v`}, - {`ALTER VIEW IF EXISTS v RENAME TO v`}, - {`ALTER MATERIALIZED VIEW v RENAME TO v`}, - {`ALTER MATERIALIZED VIEW IF EXISTS v RENAME TO v`}, - - {`ALTER SEQUENCE seq SET SCHEMA s`}, - {`ALTER SEQUENCE IF EXISTS seq SET SCHEMA s`}, - - {`COPY t FROM STDIN`}, - {`COPY t (a, b, c) FROM STDIN`}, - {`COPY crdb_internal.file_upload FROM STDIN WITH destination = 'filename'`}, - {`COPY t (a, b, c) FROM STDIN WITH BINARY`}, - {`COPY crdb_internal.file_upload FROM STDIN WITH BINARY destination = 'filename'`}, - {`COPY t (a, b, c) FROM STDIN WITH CSV DELIMITER ',' NULL 'NUL'`}, - {`COPY t (a, b, c) FROM STDIN WITH CSV DELIMITER ',' destination = 'filename'`}, - - {`ALTER TABLE a SPLIT AT VALUES (1)`}, - {`EXPLAIN ALTER TABLE a SPLIT AT VALUES (1)`}, - {`ALTER TABLE a SPLIT AT SELECT * FROM t`}, - {`ALTER TABLE d.a SPLIT AT VALUES ('b', 2)`}, - {`ALTER INDEX a@i SPLIT AT VALUES (1)`}, - {`ALTER INDEX d.a@i SPLIT AT VALUES (2)`}, - {`ALTER INDEX i SPLIT AT VALUES (1)`}, - {`ALTER INDEX d.i SPLIT AT VALUES (2)`}, - {`ALTER INDEX "primary" SPLIT AT VALUES (2)`}, - {`ALTER INDEX public.public."primary" SPLIT AT VALUES (2)`}, - {`ALTER TABLE a SPLIT AT VALUES (1) WITH EXPIRATION '1 day'`}, - {`ALTER TABLE a SPLIT AT VALUES (1) WITH EXPIRATION '1 day':::INTERVAL`}, - {`ALTER TABLE a SPLIT AT VALUES (1) WITH EXPIRATION '7258118400000000.0'`}, - {`ALTER TABLE a SPLIT AT VALUES (1) WITH EXPIRATION '2200-01-01 00:00:00.0'`}, - {`ALTER TABLE a SPLIT AT VALUES (1) WITH EXPIRATION TIMESTAMP '2200-01-01 00:00:00.0'`}, - {`ALTER TABLE a SPLIT AT VALUES (1) WITH EXPIRATION '2200-01-01 00:00:00.0':::TIMESTAMP`}, - {`ALTER TABLE a SPLIT AT VALUES (1) WITH EXPIRATION TIMESTAMPTZ '2200-01-01 00:00:00.0'`}, - - {`ALTER TABLE a UNSPLIT AT VALUES (1)`}, - {`EXPLAIN ALTER TABLE a UNSPLIT AT VALUES (1)`}, - {`ALTER TABLE a UNSPLIT AT SELECT * FROM t`}, - {`ALTER TABLE d.a UNSPLIT AT VALUES ('b', 2)`}, - {`ALTER INDEX a@i UNSPLIT AT VALUES (1)`}, - {`ALTER INDEX d.a@i UNSPLIT AT VALUES (2)`}, - {`ALTER INDEX i UNSPLIT AT VALUES (1)`}, - {`ALTER INDEX d.i UNSPLIT AT VALUES (2)`}, - {`ALTER INDEX "primary" UNSPLIT AT VALUES (2)`}, - {`ALTER INDEX public.public."primary" UNSPLIT AT VALUES (2)`}, - - {`ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[1], 1)`}, - {`EXPLAIN ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS TABLE b`}, - {`ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS SELECT * FROM t`}, - {`ALTER TABLE d.a EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[1, 2, 3], 'b', 2)`}, - {`ALTER INDEX d.i EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[1], 2)`}, - - {`ALTER TABLE a EXPERIMENTAL_RELOCATE NON_VOTERS VALUES (ARRAY[1], 1)`}, - {`EXPLAIN ALTER TABLE a EXPERIMENTAL_RELOCATE NON_VOTERS TABLE b`}, - {`ALTER TABLE a EXPERIMENTAL_RELOCATE NON_VOTERS SELECT * FROM t`}, - {`ALTER TABLE d.a EXPERIMENTAL_RELOCATE NON_VOTERS VALUES (ARRAY[1, 2, 3], 'b', 2)`}, - {`ALTER INDEX d.i EXPERIMENTAL_RELOCATE NON_VOTERS VALUES (ARRAY[1], 2)`}, - - {`ALTER TABLE a EXPERIMENTAL_RELOCATE LEASE VALUES (1, 1)`}, - {`ALTER TABLE a EXPERIMENTAL_RELOCATE LEASE SELECT * FROM t`}, - {`ALTER TABLE d.a EXPERIMENTAL_RELOCATE LEASE VALUES (1, 'b', 2)`}, - {`ALTER INDEX d.i EXPERIMENTAL_RELOCATE LEASE VALUES (1, 2)`}, - - {`ALTER TABLE a SCATTER`}, - {`EXPLAIN ALTER TABLE a SCATTER`}, - {`ALTER TABLE a SCATTER FROM (1, 2, 3) TO (4, 5, 6)`}, - {`ALTER TABLE d.a SCATTER`}, - {`ALTER INDEX d.i SCATTER FROM (1) TO (2)`}, - - {`ALTER RANGE default CONFIGURE ZONE = 'foo'`}, - {`EXPLAIN ALTER RANGE default CONFIGURE ZONE = 'foo'`}, - {`ALTER RANGE meta CONFIGURE ZONE = 'foo'`}, - - {`ALTER DATABASE db CONFIGURE ZONE = 'foo'`}, - {`EXPLAIN ALTER DATABASE db CONFIGURE ZONE = 'foo'`}, - - {`ALTER TABLE db.t CONFIGURE ZONE = 'foo'`}, - {`EXPLAIN ALTER TABLE db.t CONFIGURE ZONE = 'foo'`}, - - {`ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE = 'foo'`}, - {`EXPLAIN ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE = 'foo'`}, - - {`ALTER TABLE t CONFIGURE ZONE = 'foo'`}, - {`ALTER PARTITION p OF TABLE t CONFIGURE ZONE = 'foo'`}, - - {`ALTER INDEX i CONFIGURE ZONE = 'foo'`}, - {`EXPLAIN ALTER INDEX i CONFIGURE ZONE = 'foo'`}, - {`ALTER INDEX db.t@i CONFIGURE ZONE = 'foo'`}, - {`ALTER INDEX t@i CONFIGURE ZONE = 'foo'`}, - - {`ALTER PARTITION p OF INDEX db.t@idx CONFIGURE ZONE = 'foo'`}, - {`EXPLAIN ALTER PARTITION p OF INDEX db.t@idx CONFIGURE ZONE = 'foo'`}, - - {`ALTER TABLE t CONFIGURE ZONE = b'foo'`}, - {`ALTER TABLE t CONFIGURE ZONE = a || b`}, - - {`ALTER RANGE default CONFIGURE ZONE USING foo = bar, baz = yay`}, - {`ALTER RANGE meta CONFIGURE ZONE USING foo = bar, baz = yay`}, - {`ALTER DATABASE db CONFIGURE ZONE USING foo = bar, baz = yay`}, - {`ALTER TABLE db.t CONFIGURE ZONE USING foo = bar, baz = yay`}, - {`ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE USING foo = bar, baz = yay`}, - {`ALTER TABLE t CONFIGURE ZONE USING foo = bar, baz = yay`}, - {`ALTER PARTITION p OF TABLE t CONFIGURE ZONE USING foo = bar, baz = yay`}, - {`ALTER INDEX db.t@i CONFIGURE ZONE USING foo = bar, baz = yay`}, - {`ALTER INDEX t@i CONFIGURE ZONE USING foo = bar, baz = yay`}, - {`ALTER INDEX i CONFIGURE ZONE USING foo = bar, baz = yay`}, - {`ALTER INDEX i CONFIGURE ZONE USING foo = COPY FROM PARENT`}, - {`ALTER INDEX i CONFIGURE ZONE USING foo = bar, baz = COPY FROM PARENT`}, - {`ALTER INDEX i CONFIGURE ZONE USING foo = COPY FROM PARENT, baz = COPY FROM PARENT`}, - {`ALTER INDEX i CONFIGURE ZONE USING foo = bar, other = COPY FROM PARENT, baz = yay`}, - - {`ALTER RANGE default CONFIGURE ZONE DISCARD`}, - {`ALTER RANGE meta CONFIGURE ZONE DISCARD`}, - {`ALTER DATABASE db CONFIGURE ZONE DISCARD`}, - {`ALTER TABLE db.t CONFIGURE ZONE DISCARD`}, - {`ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE DISCARD`}, - {`ALTER TABLE t CONFIGURE ZONE DISCARD`}, - {`ALTER PARTITION p OF TABLE t CONFIGURE ZONE DISCARD`}, - {`ALTER INDEX db.t@i CONFIGURE ZONE DISCARD`}, - {`ALTER INDEX t@i CONFIGURE ZONE DISCARD`}, - {`ALTER INDEX i CONFIGURE ZONE DISCARD`}, - - {`ALTER RANGE default CONFIGURE ZONE USING DEFAULT`}, - {`ALTER RANGE meta CONFIGURE ZONE USING DEFAULT`}, - {`ALTER DATABASE db CONFIGURE ZONE USING DEFAULT`}, - {`ALTER TABLE db.t CONFIGURE ZONE USING DEFAULT`}, - {`ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE USING DEFAULT`}, - {`ALTER TABLE t CONFIGURE ZONE USING DEFAULT`}, - {`ALTER PARTITION p OF TABLE t CONFIGURE ZONE USING DEFAULT`}, - {`ALTER INDEX db.t@i CONFIGURE ZONE USING DEFAULT`}, - {`ALTER INDEX t@i CONFIGURE ZONE USING DEFAULT`}, - {`ALTER INDEX i CONFIGURE ZONE USING DEFAULT`}, - - {`ALTER TABLE t EXPERIMENTAL_AUDIT SET READ WRITE`}, - {`EXPLAIN ALTER TABLE t EXPERIMENTAL_AUDIT SET READ WRITE`}, - {`ALTER TABLE t EXPERIMENTAL_AUDIT SET OFF`}, - - {`ALTER TYPE db.s.t ADD VALUE 'hi'`}, - {`ALTER TYPE s.t ADD VALUE 'hi' BEFORE 'hello'`}, - {`ALTER TYPE t ADD VALUE 'hi' AFTER 'howdy'`}, - {`ALTER TYPE t DROP VALUE 'hi'`}, - {`ALTER TYPE s.t ADD VALUE IF NOT EXISTS 'hi' BEFORE 'hello'`}, - {`ALTER TYPE t RENAME VALUE 'value1' TO 'value2'`}, - {`ALTER TYPE t RENAME TO t2`}, - {`ALTER TYPE t SET SCHEMA newschema`}, - {`ALTER TYPE t OWNER TO foo`}, - - {`REASSIGN OWNED BY foo TO bar`}, - {`REASSIGN OWNED BY foo, bar TO third`}, - {`DROP OWNED BY foo`}, - {`DROP OWNED BY foo, bar`}, - {`DROP OWNED BY foo CASCADE`}, - {`DROP OWNED BY foo RESTRICT`}, - - {`COMMENT ON COLUMN a.b IS 'a'`}, - {`COMMENT ON COLUMN a.b IS NULL`}, - {`COMMENT ON COLUMN a.b.c IS 'a'`}, - {`COMMENT ON COLUMN a.b.c.d IS 'a'`}, - {`COMMENT ON DATABASE foo IS 'a'`}, - {`COMMENT ON DATABASE foo IS NULL`}, - {`COMMENT ON INDEX foo IS 'a'`}, - {`COMMENT ON INDEX foo IS NULL`}, - {`COMMENT ON TABLE foo IS 'a'`}, - {`COMMENT ON TABLE foo IS NULL`}, - - {`ALTER SEQUENCE a RENAME TO b`}, - {`EXPLAIN ALTER SEQUENCE a RENAME TO b`}, - {`ALTER SEQUENCE IF EXISTS a RENAME TO b`}, - - {`ALTER SEQUENCE a INCREMENT BY 5 START WITH 1000`}, - {`EXPLAIN ALTER SEQUENCE a INCREMENT BY 5 START WITH 1000`}, - {`ALTER SEQUENCE IF EXISTS a INCREMENT BY 5 START WITH 1000`}, - {`ALTER SEQUENCE IF EXISTS a NO CYCLE CACHE 1`}, - {`ALTER SEQUENCE a OWNED BY b`}, - {`ALTER SEQUENCE a OWNED BY NONE`}, - - {`EXPERIMENTAL SCRUB DATABASE x`}, - {`EXPLAIN EXPERIMENTAL SCRUB DATABASE x`}, - {`EXPERIMENTAL SCRUB DATABASE x AS OF SYSTEM TIME 1`}, - {`EXPERIMENTAL SCRUB TABLE x`}, - {`EXPLAIN EXPERIMENTAL SCRUB TABLE x`}, - {`EXPERIMENTAL SCRUB TABLE x AS OF SYSTEM TIME 1`}, - {`EXPERIMENTAL SCRUB TABLE x AS OF SYSTEM TIME 1 WITH OPTIONS INDEX ALL`}, - {`EXPERIMENTAL SCRUB TABLE x WITH OPTIONS INDEX (index_name)`}, - {`EXPERIMENTAL SCRUB TABLE x WITH OPTIONS PHYSICAL`}, - {`EXPERIMENTAL SCRUB TABLE x WITH OPTIONS CONSTRAINT ALL`}, - {`EXPERIMENTAL SCRUB TABLE x WITH OPTIONS CONSTRAINT (cst_name)`}, - {`EXPERIMENTAL SCRUB TABLE x WITH OPTIONS PHYSICAL, INDEX (index_name), CONSTRAINT (cst_name)`}, - {`EXPERIMENTAL SCRUB TABLE x WITH OPTIONS PHYSICAL, INDEX ALL, CONSTRAINT ALL`}, - - {`BACKUP TABLE foo TO 'bar'`}, - {`BACKUP TABLE foo INTO 'bar'`}, - {`BACKUP TABLE foo INTO LATEST IN 'bar'`}, - {`BACKUP TABLE foo INTO 'subdir' IN 'bar'`}, - {`BACKUP TABLE foo INTO $1 IN $2`}, - {`CREATE SCHEDULE FOR BACKUP TABLE foo INTO 'bar' RECURRING '@hourly'`}, - {`CREATE SCHEDULE 'my schedule' FOR BACKUP TABLE foo INTO 'bar' RECURRING '@daily'`}, - {`CREATE SCHEDULE FOR BACKUP TABLE foo INTO 'bar' RECURRING '@daily'`}, - {`CREATE SCHEDULE FOR BACKUP TABLE foo, bar, buz INTO 'bar' RECURRING '@daily' FULL BACKUP ALWAYS`}, - {`CREATE SCHEDULE FOR BACKUP TABLE foo, bar, buz INTO 'bar' RECURRING '@daily' FULL BACKUP '@weekly'`}, - {`CREATE SCHEDULE FOR BACKUP TABLE foo, bar, buz INTO 'bar' WITH revision_history RECURRING '@daily' FULL BACKUP '@weekly'`}, - {`CREATE SCHEDULE FOR BACKUP INTO 'bar' WITH revision_history RECURRING '@daily' FULL BACKUP '@weekly' WITH SCHEDULE OPTIONS foo = 'bar'`}, - {`EXPLAIN BACKUP TABLE foo TO 'bar'`}, - {`BACKUP TABLE foo.foo, baz.baz TO 'bar'`}, - - {`SHOW BACKUP 'bar'`}, - {`SHOW BACKUP 'bar' WITH foo = 'bar'`}, - {`EXPLAIN SHOW BACKUP 'bar'`}, - {`SHOW BACKUP RANGES 'bar'`}, - {`SHOW BACKUP FILES 'bar'`}, - {`SHOW BACKUP FILES 'bar' WITH foo = 'bar'`}, - - {`SHOW BACKUPS IN 'bar'`}, - {`SHOW BACKUPS IN $1`}, - {`SHOW BACKUP 'foo' IN 'bar'`}, - {`SHOW BACKUP $1 IN $2 WITH foo = 'bar'`}, - - {`BACKUP TABLE foo TO 'bar' AS OF SYSTEM TIME '1' INCREMENTAL FROM 'baz'`}, - {`BACKUP TABLE foo TO $1 INCREMENTAL FROM 'bar', $2, 'baz'`}, - - {`BACKUP DATABASE foo TO 'bar'`}, - {`EXPLAIN BACKUP DATABASE foo TO 'bar'`}, - {`BACKUP DATABASE foo, baz TO 'bar'`}, - {`BACKUP DATABASE foo TO 'bar' AS OF SYSTEM TIME '1' INCREMENTAL FROM 'baz'`}, - - {`BACKUP DATABASE foo TO ($1, $2)`}, - {`BACKUP DATABASE foo TO ($1, $2) INCREMENTAL FROM 'baz'`}, - - {`BACKUP TENANT 36 TO 'bar'`}, - - {`RESTORE TABLE foo FROM 'bar'`}, - {`EXPLAIN RESTORE TABLE foo FROM 'bar'`}, - {`RESTORE TABLE foo FROM $1`}, - {`RESTORE TABLE foo FROM $2 IN $1`}, - {`RESTORE TABLE foo FROM $1, $2, 'bar'`}, - {`RESTORE TABLE foo FROM 'abc' IN $1, $2, 'bar'`}, - {`RESTORE TABLE foo FROM $4 IN $1, $2, 'bar'`}, - {`RESTORE TABLE foo, baz FROM 'bar'`}, - {`RESTORE TABLE foo, baz FROM 'bar' AS OF SYSTEM TIME '1'`}, - - {`RESTORE DATABASE foo FROM 'bar'`}, - {`EXPLAIN RESTORE DATABASE foo FROM 'bar'`}, - {`RESTORE DATABASE foo, baz FROM 'bar'`}, - {`RESTORE DATABASE foo, baz FROM 'bar' AS OF SYSTEM TIME '1'`}, - - {`RESTORE DATABASE foo FROM ($1, $2)`}, - {`RESTORE DATABASE foo FROM ($1, $2), $3`}, - {`RESTORE DATABASE foo FROM $1, ($2, $3)`}, - {`RESTORE DATABASE foo FROM ($1, $2), ($3, $4)`}, - {`RESTORE DATABASE foo FROM ($1, $2), ($3, $4) AS OF SYSTEM TIME '1'`}, - - {`RESTORE FROM ($1, $2)`}, - {`RESTORE FROM ($1, $2), $3`}, - {`RESTORE FROM $1, ($2, $3)`}, - {`RESTORE FROM ($1, $2), ($3, $4)`}, - {`RESTORE FROM ($1, $2), ($3, $4) AS OF SYSTEM TIME '1'`}, - {`RESTORE FROM $4 IN $1, $2, 'bar'`}, - {`RESTORE FROM $4 IN $1, $2, 'bar' AS OF SYSTEM TIME '1' WITH skip_missing_foreign_keys`}, - - {`RESTORE TENANT 36 FROM ($1, $2) AS OF SYSTEM TIME '1'`}, - - {`RESTORE TENANT 123 FROM REPLICATION STREAM FROM 'bar'`}, - {`RESTORE TENANT 123 FROM REPLICATION STREAM FROM $1`}, - {`RESTORE TENANT 123 FROM REPLICATION STREAM FROM 'bar' AS OF SYSTEM TIME '1'`}, - {`RESTORE TENANT 123 FROM REPLICATION STREAM FROM $1 AS OF SYSTEM TIME '1'`}, - - // Currently, we only support TENANT as a target. We have grammar rules for - // all targets supported by RESTORE but these will error out during the - // planning phase. - {`RESTORE TABLE foo FROM REPLICATION STREAM FROM 'bar'`}, - {`RESTORE TABLE foo FROM REPLICATION STREAM FROM $1`}, - {`RESTORE DATABASE foodb FROM REPLICATION STREAM FROM 'baz'`}, - {`RESTORE DATABASE foodb FROM REPLICATION STREAM FROM $1`}, - - {`BACKUP TABLE foo TO 'bar' WITH revision_history, detached`}, - {`RESTORE TABLE foo FROM 'bar' WITH skip_missing_foreign_keys, skip_missing_sequences, detached`}, - - {`IMPORT TABLE foo CREATE USING 'nodelocal://0/some/file' CSV DATA ('path/to/some/file', $1) WITH temp = 'path/to/temp'`}, - {`EXPLAIN IMPORT TABLE foo CREATE USING 'nodelocal://0/some/file' CSV DATA ('path/to/some/file', $1) WITH temp = 'path/to/temp'`}, - {`IMPORT TABLE foo CREATE USING 'nodelocal://0/some/file' DELIMITED DATA ('path/to/some/file', $1)`}, - {`IMPORT TABLE foo (id INT8 PRIMARY KEY, email STRING, age INT8) CSV DATA ('path/to/some/file', $1) WITH temp = 'path/to/temp'`}, - {`IMPORT TABLE foo (id INT8, email STRING, age INT8) CSV DATA ('path/to/some/file', $1) WITH comma = ',', "nullif" = 'n/a', temp = $2`}, - {`IMPORT TABLE foo FROM PGDUMPCREATE 'nodelocal://0/foo/bar' WITH temp = 'path/to/temp'`}, - {`IMPORT INTO foo(id, email) CSV DATA ('path/to/some/file', $1) WITH temp = 'path/to/temp'`}, - {`IMPORT INTO foo CSV DATA ('path/to/some/file', $1) WITH temp = 'path/to/temp'`}, - {`IMPORT TABLE a.foo (LIKE tab, col INT8 CONSTRAINT conname NULL NOT VISIBLE) CSV DATA ('placeholder')`}, - - {`IMPORT PGDUMP 'nodelocal://0/foo/bar' WITH temp = 'path/to/temp'`}, - {`EXPLAIN IMPORT PGDUMP 'nodelocal://0/foo/bar' WITH temp = 'path/to/temp'`}, - - {`EXPORT INTO CSV 'a' FROM TABLE a`}, // TODO(knz): Make this explainable. - {`EXPORT INTO CSV 'a' FROM SELECT * FROM a`}, - {`EXPORT INTO CSV 's3://my/path/%part%.csv' WITH delimiter = '|' FROM TABLE a`}, - {`EXPORT INTO CSV 's3://my/path/%part%.csv' WITH delimiter = '|' FROM SELECT a, sum(b) FROM c WHERE d = 1 ORDER BY sum(b) DESC LIMIT 10`}, - - {`SET ROW (1, true, NULL)`}, - - {`EXPERIMENTAL CHANGEFEED FOR TABLE foo`}, - {`EXPLAIN CREATE CHANGEFEED FOR TABLE foo INTO 'sink'`}, - {`CREATE CHANGEFEED FOR TABLE foo, db.bar, schema.db.foo INTO 'sink'`}, - {`CREATE CHANGEFEED FOR TABLE foo INTO 'sink'`}, - // TODO(dan): Implement. - // {`CREATE CHANGEFEED FOR TABLE foo VALUES FROM (1) TO (2) INTO 'sink'`}, - // {`CREATE CHANGEFEED FOR TABLE foo PARTITION bar, baz INTO 'sink'`}, - // {`CREATE CHANGEFEED FOR DATABASE foo INTO 'sink'`}, - {`CREATE CHANGEFEED FOR TABLE foo INTO 'sink' WITH bar = 'baz'`}, - - {`CREATE REPLICATION STREAM FOR TENANT 1`}, - {`CREATE REPLICATION STREAM FOR TENANT 1 WITH CURSOR='start'`}, - {`CREATE REPLICATION STREAM FOR TENANT 1 INTO 'sink'`}, - {`CREATE REPLICATION STREAM FOR TENANT 1 INTO 'sink' WITH CURSOR='start', DETACHED`}, - {`CREATE REPLICATION STREAM FOR DATABASE a, b, c`}, - {`CREATE REPLICATION STREAM FOR TABLE t`}, - - // Regression for #15926 - {`SELECT * FROM ((t1 NATURAL JOIN t2 WITH ORDINALITY AS o1)) WITH ORDINALITY AS o2`}, - - {`WITH cte AS (SELECT 1) SELECT * FROM cte`}, - {`WITH cte (x) AS (INSERT INTO abc VALUES (1, 2)), cte2 (y) AS (SELECT x + 1 FROM cte) SELECT * FROM cte, cte2`}, - {`WITH RECURSIVE cte (x) AS (SELECT 1), cte2 (y) AS (SELECT x + 1 FROM cte) SELECT 1`}, - {`WITH cte AS MATERIALIZED (SELECT 1) SELECT * FROM cte`}, - {`WITH RECURSIVE cte AS MATERIALIZED (SELECT 1) SELECT * FROM cte`}, - {`WITH cte AS NOT MATERIALIZED (SELECT 1) SELECT * FROM cte`}, - {`WITH cte (x) AS MATERIALIZED (INSERT INTO abc VALUES (1, 2)), cte2 (y) AS NOT MATERIALIZED (SELECT x + 1 FROM cte) SELECT * FROM cte, cte2`}, - {`WITH RECURSIVE cte (x) AS MATERIALIZED (INSERT INTO abc VALUES (1, 2)), cte2 (y) AS NOT MATERIALIZED (SELECT x + 1 FROM cte) SELECT * FROM cte, cte2`}, - } - var p parser.Parser // Verify that the same parser can be reused. - for _, d := range testData { - stmts, err := p.Parse(d.sql) - if err != nil { - t.Fatalf("%s: expected success, but found %s", d.sql, err) - } - s := stmts.String() - if d.sql != s { - t.Errorf("expected \n%q\n, but found \n%q", d.sql, s) - } - sqlutils.VerifyStatementPrettyRoundtrip(t, d.sql) - } -} - -// TestParse2 verifies that we can parse the supplied SQL and regenerate the -// expected SQL string from the syntax tree. Note that if the input and output -// SQL strings are the same, the test case should go in TestParse instead. -func TestParse2(t *testing.T) { - testData := []struct { - sql string - expected string - }{ - {`CREATE DATABASE a WITH ENCODING = 'foo'`, - `CREATE DATABASE a ENCODING = 'foo'`}, - {`CREATE DATABASE a TEMPLATE = template0`, - `CREATE DATABASE a TEMPLATE = 'template0'`}, - {`CREATE DATABASE a TEMPLATE = invalid`, - `CREATE DATABASE a TEMPLATE = 'invalid'`}, - { - `CREATE DATABASE a WITH CONNECTION LIMIT = 13`, - `CREATE DATABASE a CONNECTION LIMIT = 13`, - }, - { - `CREATE DATABASE a WITH CONNECTION LIMIT -1`, - `CREATE DATABASE a`, - }, - { - `CREATE DATABASE IF NOT EXISTS a SURVIVE = ZONE FAILURE`, - `CREATE DATABASE IF NOT EXISTS a SURVIVE ZONE FAILURE`, - }, - { - `CREATE DATABASE IF NOT EXISTS a SURVIVE = REGION FAILURE`, - `CREATE DATABASE IF NOT EXISTS a SURVIVE REGION FAILURE`, - }, - { - `CREATE DATABASE IF NOT EXISTS a SURVIVE = AVAILABILITY ZONE FAILURE`, - `CREATE DATABASE IF NOT EXISTS a SURVIVE ZONE FAILURE`, - }, - { - `CREATE DATABASE a REGION "us-west-1"`, - `CREATE DATABASE a REGIONS = "us-west-1"`, - }, - { - `CREATE DATABASE a PRIMARY REGION = "us-west-1"`, - `CREATE DATABASE a PRIMARY REGION "us-west-1"`, - }, - {`ALTER DATABASE a SET PRIMARY REGION "us-west-1"`, - `ALTER DATABASE a PRIMARY REGION "us-west-1"`}, - - {`CREATE TABLE a (b INT) WITH (fillfactor=100)`, - `CREATE TABLE a (b INT8)`}, - {`CREATE TABLE a (b INT, UNIQUE INDEX foo (b))`, - `CREATE TABLE a (b INT8, CONSTRAINT foo UNIQUE (b))`}, - {`CREATE TABLE a (b INT, UNIQUE INDEX foo (b) WHERE c > 3)`, - `CREATE TABLE a (b INT8, CONSTRAINT foo UNIQUE (b) WHERE c > 3)`}, - {`CREATE TABLE a (b INT, UNIQUE INDEX foo (b) INTERLEAVE IN PARENT c (d))`, - `CREATE TABLE a (b INT8, CONSTRAINT foo UNIQUE (b) INTERLEAVE IN PARENT c (d))`}, - {`CREATE TABLE a (UNIQUE 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) COVERING (c)`, `CREATE INDEX ON a (b) STORING (c)`}, - {`CREATE INDEX ON a (b) INCLUDE (c)`, `CREATE INDEX ON a (b) STORING (c)`}, - - {`CREATE INDEX a ON b USING GIN (c)`, - `CREATE INVERTED INDEX a ON b (c)`}, - {`CREATE INDEX a ON b USING GIST (c)`, - `CREATE INVERTED INDEX a ON b (c)`}, - {`CREATE UNIQUE INDEX a ON b USING GIN (c)`, - `CREATE UNIQUE INVERTED INDEX a ON b (c)`}, - - {`CREATE INDEX ON a (a, (lower(b)))`, - `CREATE INDEX ON a (a, lower(b))`}, - - {`CREATE INDEX ON a ((lower(a) || ' ' || lower(b)))`, - `CREATE INDEX ON a (((lower(a) || ' ') || lower(b)))`}, - - {`CREATE TABLE a (b BIGSERIAL, c SMALLSERIAL, d SERIAL)`, - `CREATE TABLE a (b SERIAL8, c SERIAL2, d SERIAL8)`}, - {`CREATE TABLE a (b BIGINT, c SMALLINT, d INTEGER, e INT)`, - `CREATE TABLE a (b INT8, c INT2, d INT8, e INT8)`}, - {`CREATE TABLE a (b FLOAT, c FLOAT(10), d FLOAT(40), e REAL, f DOUBLE PRECISION)`, - `CREATE TABLE a (b FLOAT8, c FLOAT4, d FLOAT8, e FLOAT4, f FLOAT8)`}, - {`CREATE TABLE a (b NUMERIC, c NUMERIC(10), d DEC)`, - `CREATE TABLE a (b DECIMAL, c DECIMAL(10), d DECIMAL)`}, - {`CREATE TABLE a (b BOOLEAN)`, - `CREATE TABLE a (b BOOL)`}, - {`CREATE TABLE a (b TEXT)`, - `CREATE TABLE a (b STRING)`}, - {`CREATE TABLE a (b JSON)`, - `CREATE TABLE a (b JSONB)`}, - {`CREATE TABLE a (b TIMESTAMP WITH TIME ZONE)`, - `CREATE TABLE a (b TIMESTAMPTZ)`}, - {`CREATE TABLE a (b BYTES, c BYTEA, d BLOB)`, - `CREATE TABLE a (b BYTES, c BYTES, d BYTES)`}, - {`CREATE TABLE a (b CHAR(1), c CHARACTER(1), d CHARACTER(3))`, - `CREATE TABLE a (b CHAR, c CHAR, d CHAR(3))`}, - {`CREATE TABLE a (b CHAR VARYING, c CHARACTER VARYING(3))`, - `CREATE TABLE a (b VARCHAR, c VARCHAR(3))`}, - {`CREATE TABLE a (b BIT VARYING(2), c BIT(1))`, - `CREATE TABLE a (b VARBIT(2), c BIT)`}, - - {`CREATE TABLE a (b INT, CHECK (b > 0) NOT VALID)`, - `CREATE TABLE a (b INT8, CHECK (b > 0))`}, - {`CREATE TABLE a (b INT, FOREIGN KEY (b) REFERENCES other (b) NOT VALID)`, - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other (b))`}, - - {`CREATE STATISTICS a ON col1 FROM t AS OF SYSTEM TIME '2016-01-01'`, - `CREATE STATISTICS a ON col1 FROM t WITH OPTIONS AS OF SYSTEM TIME '2016-01-01'`}, - - {`ANALYSE t`, `ANALYZE t`}, +// TestParseDataDriven verifies that we can parse the supplied SQL and regenerate the SQL +// string from the syntax tree. +func TestParseDatadriven(t *testing.T) { + datadriven.Walk(t, "testdata/parse", func(t *testing.T, path string) { + datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string { + switch d.Cmd { + case "parse": + // Check parse. + stmts, err := parser.Parse(d.Input) + if err != nil { + d.Fatalf(t, "unexpected parse error: %v", err) + } - { - `ALTER TABLE a EXPERIMENTAL_RELOCATE VALUES (ARRAY[1], 1)`, - `ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[1], 1)`, - }, - { - `EXPLAIN ALTER TABLE a EXPERIMENTAL_RELOCATE TABLE b`, - `EXPLAIN ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS TABLE b`, - }, - { - `ALTER TABLE a EXPERIMENTAL_RELOCATE SELECT * FROM t`, - `ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS SELECT * FROM t`, - }, - { - `ALTER TABLE d.a EXPERIMENTAL_RELOCATE VALUES (ARRAY[1, 2, 3], 'b', 2)`, - `ALTER TABLE d.a EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[1, 2, 3], 'b', 2)`, - }, - { - `ALTER INDEX d.i EXPERIMENTAL_RELOCATE VALUES (ARRAY[1], 2)`, - `ALTER INDEX d.i EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[1], 2)`, - }, + // Check pretty-print roundtrip via the sqlfmt logic. + sqlutils.VerifyStatementPrettyRoundtrip(t, d.Input) - {`SELECT TIMESTAMP WITHOUT TIME ZONE 'foo'`, `SELECT TIMESTAMP 'foo'`}, - {`SELECT CAST('foo' AS TIMESTAMP WITHOUT TIME ZONE)`, `SELECT CAST('foo' AS TIMESTAMP)`}, - {`SELECT CAST(1 AS "timestamp")`, `SELECT CAST(1 AS TIMESTAMP)`}, - {`SELECT CAST(1 AS _int8)`, `SELECT CAST(1 AS INT8[])`}, - {`SELECT CAST(1 AS "_int8")`, `SELECT CAST(1 AS INT8[])`}, - {`SELECT SERIAL8 'foo', 'foo'::SERIAL8`, `SELECT INT8 'foo', 'foo'::INT8`}, - - {`SELECT 'a'::TIMESTAMP(3)`, `SELECT 'a'::TIMESTAMP(3)`}, - {`SELECT 'a'::TIMESTAMP(3) WITHOUT TIME ZONE`, `SELECT 'a'::TIMESTAMP(3)`}, - {`SELECT 'a'::TIMESTAMPTZ(3)`, `SELECT 'a'::TIMESTAMPTZ(3)`}, - {`SELECT 'a'::TIMESTAMP(3) WITH TIME ZONE`, `SELECT 'a'::TIMESTAMPTZ(3)`}, - {`SELECT TIMESTAMP(3) 'a'`, `SELECT TIMESTAMP(3) 'a'`}, - {`SELECT TIMESTAMPTZ(3) 'a'`, `SELECT TIMESTAMPTZ(3) 'a'`}, - - {`SELECT 'a'::TIME(3)`, `SELECT 'a'::TIME(3)`}, - {`SELECT 'a'::TIME(3) WITHOUT TIME ZONE`, `SELECT 'a'::TIME(3)`}, - {`SELECT 'a'::TIMETZ(3)`, `SELECT 'a'::TIMETZ(3)`}, - {`SELECT 'a'::TIME(3) WITH TIME ZONE`, `SELECT 'a'::TIMETZ(3)`}, - {`SELECT TIME(3) 'a'`, `SELECT TIME(3) 'a'`}, - {`SELECT TIMETZ(3) 'a'`, `SELECT TIMETZ(3) 'a'`}, - - {`SELECT 'a' FROM t@{FORCE_INDEX=bar}`, `SELECT 'a' FROM t@bar`}, - {`SELECT 'a' FROM t@{ASC,FORCE_INDEX=idx}`, `SELECT 'a' FROM t@{FORCE_INDEX=idx,ASC}`}, - - {`SELECT 'a' FROM t@{FORCE_INDEX=[123]}`, `SELECT 'a' FROM t@[123]`}, - {`SELECT 'a' FROM [123 AS t]@{FORCE_INDEX=[456]}`, `SELECT 'a' FROM [123 AS t]@[456]`}, - - {`SELECT a FROM t WHERE a ISNULL`, `SELECT a FROM t WHERE a IS NULL`}, - {`SELECT a FROM t WHERE a NOTNULL`, `SELECT a FROM t WHERE a IS NOT NULL`}, - {`SELECT a FROM t WHERE a IS UNKNOWN`, `SELECT a FROM t WHERE a IS NOT DISTINCT FROM NULL`}, - {`SELECT a FROM t WHERE a IS NOT UNKNOWN`, `SELECT a FROM t WHERE a IS DISTINCT FROM NULL`}, - - {`SELECT +1`, `SELECT 1`}, - {`SELECT - - 5`, `SELECT 5`}, - {`SELECT - + 5`, `SELECT -5`}, - {`SELECT a FROM t WHERE b = - 2`, `SELECT a FROM t WHERE b = -2`}, - {`SELECT a FROM t WHERE a = b AND a = c`, `SELECT a FROM t WHERE (a = b) AND (a = c)`}, - {`SELECT a FROM t WHERE a = b OR a = c`, `SELECT a FROM t WHERE (a = b) OR (a = c)`}, - {`SELECT a FROM t WHERE NOT a = b`, `SELECT a FROM t WHERE NOT (a = b)`}, - - {`SELECT a FROM t WHERE a = b & c`, `SELECT a FROM t WHERE a = (b & c)`}, - {`SELECT a FROM t WHERE a = b | c`, `SELECT a FROM t WHERE a = (b | c)`}, - {`SELECT a FROM t WHERE a = b # c`, `SELECT a FROM t WHERE a = (b # c)`}, - {`SELECT a FROM t WHERE a = b ^ c`, `SELECT a FROM t WHERE a = (b ^ c)`}, - {`SELECT a FROM t WHERE a = b + c`, `SELECT a FROM t WHERE a = (b + c)`}, - {`SELECT a FROM t WHERE a = b - c`, `SELECT a FROM t WHERE a = (b - c)`}, - {`SELECT a FROM t WHERE a = b * c`, `SELECT a FROM t WHERE a = (b * c)`}, - {`SELECT a FROM t WHERE a = b / c`, `SELECT a FROM t WHERE a = (b / c)`}, - {`SELECT a FROM t WHERE a = b % c`, `SELECT a FROM t WHERE a = (b % c)`}, - {`SELECT a FROM t WHERE a = b || c`, `SELECT a FROM t WHERE a = (b || c)`}, - {`SELECT a FROM t WHERE a = + b`, `SELECT a FROM t WHERE a = b`}, - {`SELECT a FROM t WHERE a = - b`, `SELECT a FROM t WHERE a = (-b)`}, - {`SELECT a FROM t WHERE a = ~ b`, `SELECT a FROM t WHERE a = (~b)`}, - - {`SELECT b <<= c`, `SELECT inet_contained_by_or_equals(b, c)`}, - {`SELECT b >>= c`, `SELECT inet_contains_or_equals(b, c)`}, - - {`SELECT NUMERIC 'foo'`, `SELECT DECIMAL 'foo'`}, - {`SELECT REAL 'foo'`, `SELECT FLOAT4 'foo'`}, - {`SELECT DOUBLE PRECISION 'foo'`, `SELECT FLOAT8 'foo'`}, - - // Escaped string literals are not always escaped the same because - // '''' and e'\'' scan to the same token. It's more convenient to - // prefer escaping ' and \, so we do that. - {`SELECT 'a''a'`, - `SELECT e'a\'a'`}, - {`SELECT 'a\a'`, - `SELECT e'a\\a'`}, - {`SELECT 'a\n'`, - `SELECT e'a\\n'`}, - {"SELECT '\n'", - `SELECT e'\n'`}, - {"SELECT '\n\\'", - `SELECT e'\n\\'`}, - {`SELECT "a'a" FROM t`, - `SELECT "a'a" FROM t`}, - // Hexadecimal literal strings are turned into regular strings. - {`SELECT x'61'`, `SELECT b'a'`}, - {`SELECT X'61'`, `SELECT b'a'`}, - // Comments are stripped. - {`SELECT 1 FROM t -- hello world`, - `SELECT 1 FROM t`}, - {`SELECT /* hello world */ 1 FROM t`, - `SELECT 1 FROM t`}, - {`SELECT /* hello */ 1 FROM /* world */ t`, - `SELECT 1 FROM t`}, - // Alias expressions are always output using AS. - {`SELECT 1 FROM t t1`, - `SELECT 1 FROM t AS t1`}, - {`SELECT 1 FROM t t1 (c1, c2)`, - `SELECT 1 FROM t AS t1 (c1, c2)`}, - // Alternate not-equal operator. - {`SELECT a FROM t WHERE a <> b`, - `SELECT a FROM t WHERE a != b`}, - // BETWEEN ASYMMETRIC is noise for BETWEEN. - {`SELECT a FROM t WHERE a BETWEEN ASYMMETRIC b AND c`, - `SELECT a FROM t WHERE a BETWEEN b AND c`}, - // OUTER is syntactic sugar. - {`SELECT a FROM t1 LEFT OUTER JOIN t2 ON a = b`, - `SELECT a FROM t1 LEFT JOIN t2 ON a = b`}, - {`SELECT a FROM t1 RIGHT OUTER JOIN t2 ON a = b`, - `SELECT a FROM t1 RIGHT JOIN t2 ON a = b`}, - {`SELECT a FROM t1 RIGHT OUTER MERGE JOIN t2 ON a = b`, - `SELECT a FROM t1 RIGHT MERGE JOIN t2 ON a = b`}, - // Some functions are nearly keywords. - {`SELECT CURRENT_SCHEMA`, - `SELECT current_schema()`}, - {`SELECT CURRENT_CATALOG`, - `SELECT current_database()`}, - {`SELECT CURRENT_TIMESTAMP`, - `SELECT current_timestamp()`}, - {`SELECT current_timestamp(6)`, - `SELECT current_timestamp(6)`}, - {`SELECT CURRENT_TIME`, - `SELECT current_time()`}, - {`SELECT current_time(6)`, - `SELECT current_time(6)`}, - {`SELECT CURRENT_DATE`, - `SELECT current_date()`}, - {`SELECT POSITION(a IN b)`, - `SELECT strpos(b, a)`}, - {`SELECT TRIM(BOTH a FROM b)`, - `SELECT btrim(b, a)`}, - {`SELECT TRIM(LEADING a FROM b)`, - `SELECT ltrim(b, a)`}, - {`SELECT TRIM(TRAILING a FROM b)`, - `SELECT rtrim(b, a)`}, - {`SELECT TRIM(a, b)`, - `SELECT btrim(a, b)`}, - {`SELECT CURRENT_USER`, - `SELECT current_user()`}, - {`SELECT CURRENT_ROLE`, - `SELECT current_user()`}, - {`SELECT SESSION_USER`, - `SELECT current_user()`}, - {`SELECT USER`, - `SELECT current_user()`}, - // Offset has an optional ROW/ROWS keyword. - {`SELECT a FROM t1 OFFSET a ROW`, - `SELECT a FROM t1 OFFSET a`}, - {`SELECT a FROM t1 OFFSET a ROWS`, - `SELECT a FROM t1 OFFSET a`}, - // We allow OFFSET before LIMIT, but always output LIMIT first. - {`SELECT a FROM t OFFSET a LIMIT b`, - `SELECT a FROM t LIMIT b OFFSET a`}, - // FETCH FIRST ... is alternative syntax for LIMIT. - {`SELECT a FROM t FETCH FIRST 3 ROWS ONLY`, - `SELECT a FROM t LIMIT 3`}, - {`SELECT a FROM t FETCH NEXT 3 ROWS ONLY`, - `SELECT a FROM t LIMIT 3`}, - {`SELECT a FROM t FETCH FIRST ROW ONLY`, - `SELECT a FROM t LIMIT 1`}, - {`SELECT a FROM t FETCH FIRST (2 * a) ROWS ONLY`, - `SELECT a FROM t LIMIT (2 * a)`}, - {`SELECT a FROM t OFFSET b FETCH FIRST (2 * a) ROWS ONLY`, - `SELECT a FROM t LIMIT (2 * a) OFFSET b`}, - {`SELECT a FROM t FETCH FIRST (2 * a) ROWS ONLY OFFSET b ROWS`, - `SELECT a FROM t LIMIT (2 * a) OFFSET b`}, - {`SELECT a FROM t FETCH FIRST $1 ROWS ONLY OFFSET $2 ROWS`, - `SELECT a FROM t LIMIT $1 OFFSET $2`}, - {`SELECT a FROM t FETCH FIRST +3 ROWS ONLY OFFSET +3 ROWS`, - `SELECT a FROM t LIMIT 3 OFFSET 3`}, - {`SELECT a FROM t FETCH FIRST -3 ROWS ONLY OFFSET -3 ROWS`, - `SELECT a FROM t LIMIT -3 OFFSET -3`}, - {`SELECT a FROM t FETCH FIRST +3.0 ROWS ONLY OFFSET +3.0 ROWS`, - `SELECT a FROM t LIMIT 3.0 OFFSET 3.0`}, - {`SELECT a FROM t FETCH FIRST -3.0 ROWS ONLY OFFSET -3.0 ROWS`, - `SELECT a FROM t LIMIT -3.0 OFFSET -3.0`}, - // Double negation. See #1800. - {`SELECT *,-/* comment */-5`, - `SELECT *, 5`}, - {"SELECT -\n-5", - `SELECT 5`}, - {`SELECT -0.-/*test*/-1`, - `SELECT -0. - -1`, - }, - // See #1948. - {`SELECT~~+~++~bd(*)`, - `SELECT ~(~(~(~bd(*))))`}, - // See #1957. - {`SELECT+y[array[]]`, - `SELECT y[ARRAY[]]`}, - {`SELECT a FROM t UNION DISTINCT SELECT 1 FROM t`, - `SELECT a FROM t UNION SELECT 1 FROM t`}, - {`SELECT a FROM t EXCEPT DISTINCT SELECT 1 FROM t`, - `SELECT a FROM t EXCEPT SELECT 1 FROM t`}, - {`SELECT a FROM t INTERSECT DISTINCT SELECT 1 FROM t`, - `SELECT a FROM t INTERSECT SELECT 1 FROM t`}, - - {`SELECT a #- '{x}'`, `SELECT json_remove_path(a, '{x}')`}, - - {`SELECT 'a' LIKE '\a' ESCAPE '\'`, `SELECT like_escape('a', e'\\a', e'\\')`}, - {`SELECT '\abc\' LIKE '-\___-\' ESCAPE '-'`, `SELECT like_escape(e'\\abc\\', e'-\\___-\\', '-')`}, - {`SELECT 'a' LIKE '\a' ESCAPE ''`, `SELECT like_escape('a', e'\\a', '')`}, - {`SELECT 'a' NOT LIKE '\a' ESCAPE '\'`, `SELECT not_like_escape('a', e'\\a', e'\\')`}, - {`SELECT '\abc\' NOT LIKE '-\___-\' ESCAPE '-'`, `SELECT not_like_escape(e'\\abc\\', e'-\\___-\\', '-')`}, - {`SELECT 'a' NOT LIKE '\a' ESCAPE ''`, `SELECT not_like_escape('a', e'\\a', '')`}, - {`SELECT 'a' ILIKE '\a' ESCAPE '\'`, `SELECT ilike_escape('a', e'\\a', e'\\')`}, - {`SELECT '\abc\' ILIKE '-\___-\' ESCAPE '-'`, `SELECT ilike_escape(e'\\abc\\', e'-\\___-\\', '-')`}, - {`SELECT 'a' ILIKE '\a' ESCAPE ''`, `SELECT ilike_escape('a', e'\\a', '')`}, - {`SELECT 'a' NOT ILIKE '\a' ESCAPE '\'`, `SELECT not_ilike_escape('a', e'\\a', e'\\')`}, - {`SELECT '\abc\' NOT ILIKE '-\___-\' ESCAPE '-'`, `SELECT not_ilike_escape(e'\\abc\\', e'-\\___-\\', '-')`}, - {`SELECT 'a' NOT ILIKE '\a' ESCAPE ''`, `SELECT not_ilike_escape('a', e'\\a', '')`}, - {`SELECT 'a' SIMILAR TO '\a' ESCAPE '\'`, `SELECT similar_to_escape('a', e'\\a', e'\\')`}, - {`SELECT '\abc\' SIMILAR TO '-\___-\' ESCAPE '-'`, `SELECT similar_to_escape(e'\\abc\\', e'-\\___-\\', '-')`}, - {`SELECT 'a' SIMILAR TO '\a' ESCAPE ''`, `SELECT similar_to_escape('a', e'\\a', '')`}, - {`SELECT 'a' NOT SIMILAR TO '\a' ESCAPE '\'`, `SELECT not_similar_to_escape('a', e'\\a', e'\\')`}, - {`SELECT '\abc\' NOT SIMILAR TO '-\___-\' ESCAPE '-'`, `SELECT not_similar_to_escape(e'\\abc\\', e'-\\___-\\', '-')`}, - {`SELECT 'a' NOT SIMILAR TO '\a' ESCAPE ''`, `SELECT not_similar_to_escape('a', e'\\a', '')`}, - - // using dollar-quotes - {`SELECT $$a'a$$`, `SELECT e'a\'a'`}, - {`SELECT $$a\\na$$`, `SELECT e'a\\\\na'`}, - {`SELECT $select$\\n$select$`, `SELECT e'\\\\n'`}, - {`SELECT $$a"a$$`, `SELECT 'a"a'`}, - {`SELECT $$full$$`, `SELECT 'full'`}, // must quote column name keyword - {`SELECT $select$full$select$`, `SELECT 'full'`}, - {`SELECT $select$a$$b$select$`, `SELECT 'a$$b'`}, - {`SELECT $$Dianne's horse$$`, `SELECT e'Dianne\'s horse'`}, - {`SELECT $SomeTag$Dianne's horse$SomeTag$`, `SELECT e'Dianne\'s horse'`}, - {`SELECT $function$ -BEGIN -RETURN ($1 ~ $q$[\t\r\n\v\\]$q$); -END; -$function$`, - `SELECT e'\nBEGIN\nRETURN ($1 ~ $q$[\\t\\r\\n\\v\\\\]$q$);\nEND;\n'`}, - - {`SELECT (ARRAY (1, 2))[1]`, `SELECT (ARRAY[1, 2])[1]`}, - - // Interval constructor gets eagerly processed. - {`SELECT INTERVAL '0'`, `SELECT '00:00:00'`}, - {`SELECT INTERVAL '1' SECOND`, `SELECT '00:00:01'`}, - {`SELECT INTERVAL(3) '12.1234s'`, `SELECT '00:00:12.123'`}, - {`SELECT INTERVAL '12.1234s' SECOND(3)`, `SELECT '00:00:12.123'`}, - {`SELECT INTERVAL '14.7899s' SECOND(3)`, `SELECT '00:00:14.79'`}, // Check rounding. - - {`SELECT '11s'::INTERVAL(3)`, `SELECT '11s'::INTERVAL(3)`}, - {`SELECT '10:00:13.123456'::INTERVAL SECOND`, `SELECT '10:00:13.123456'::INTERVAL SECOND`}, - {`SELECT '10:00:13.123456'::INTERVAL SECOND(3)`, `SELECT '10:00:13.123456'::INTERVAL SECOND(3)`}, - {`SELECT '10:00:13.123456'::INTERVAL MINUTE TO SECOND`, `SELECT '10:00:13.123456'::INTERVAL MINUTE TO SECOND`}, - {`SELECT '10:00:13.123456'::INTERVAL MINUTE TO SECOND(3)`, `SELECT '10:00:13.123456'::INTERVAL MINUTE TO SECOND(3)`}, - - // Pretty printing the FAMILY INET function is not normal due to the grammar - // definition of FAMILY. - {`SELECT FAMILY(x)`, // lint: uppercase function OK - `SELECT "family"(x)`}, - - {`SET SCHEMA 'public'`, - `SET search_path = 'public'`}, - {`SET TIME ZONE 'pst8pdt'`, - `SET timezone = 'pst8pdt'`}, - {`SET TIME ZONE 'Europe/Rome'`, - `SET timezone = 'Europe/Rome'`}, - {`SET TIME ZONE -7`, - `SET timezone = -7`}, - {`SET TIME ZONE -7.3`, - `SET timezone = -7.3`}, - {`SET TIME ZONE DEFAULT`, - `SET timezone = DEFAULT`}, - {`SET TIME ZONE LOCAL`, - `SET timezone = 'local'`}, - {`SET TIME ZONE pst8pdt`, - `SET timezone = 'pst8pdt'`}, - {`SET TIME ZONE "Europe/Rome"`, - `SET timezone = 'Europe/Rome'`}, - {`SET TIME ZONE INTERVAL '-7h'`, - `SET timezone = '-07:00:00'`}, - {`SET TIME ZONE INTERVAL(3) '-7h'`, - `SET timezone = '-07:00:00'`}, - {`SET TIME ZONE INTERVAL '-7h0m5s' HOUR TO MINUTE`, - `SET timezone = '-06:59:00'`}, - {`SET CLUSTER SETTING a = on`, - `SET CLUSTER SETTING a = "on"`}, - {`SET a = on`, - `SET a = "on"`}, - {`SET a = default`, - `SET a = DEFAULT`}, - - // Special substring syntax - {`SELECT SUBSTRING('RoacH' from 2 for 3)`, - `SELECT substring('RoacH', 2, 3)`}, - {`SELECT SUBSTRING('RoacH' for 2 from 3)`, - `SELECT substring('RoacH', 3, 2)`}, - {`SELECT SUBSTRING('RoacH' from 2)`, - `SELECT substring('RoacH', 2)`}, - {`SELECT SUBSTRING('RoacH' for 3)`, - `SELECT substring('RoacH', 1, 3)`}, - {`SELECT SUBSTRING('f(oabaroob' from '\(o(.)b')`, - `SELECT substring('f(oabaroob', e'\\(o(.)b')`}, - {`SELECT SUBSTRING('f(oabaroob' from '+(o(.)b' for '+')`, - `SELECT substring('f(oabaroob', '+(o(.)b', '+')`}, - // Special position syntax - {`SELECT POSITION('ig' in 'high')`, - `SELECT strpos('high', 'ig')`}, - // Special overlay syntax - {`SELECT OVERLAY('w33333rce' PLACING 'resou' FROM 3)`, - `SELECT overlay('w33333rce', 'resou', 3)`}, - {`SELECT OVERLAY('w33333rce' PLACING 'resou' FROM 3 FOR 5)`, - `SELECT overlay('w33333rce', 'resou', 3, 5)`}, - // Special extract syntax - {`SELECT EXTRACT(second from now())`, - `SELECT extract('second', now())`}, - {`SELECT EXTRACT('second' from now())`, - `SELECT extract('second', now())`}, - // Special trim syntax - {`SELECT TRIM('xy' from 'xyxtrimyyx')`, - `SELECT btrim('xyxtrimyyx', 'xy')`}, - {`SELECT TRIM(both 'xy' from 'xyxtrimyyx')`, - `SELECT btrim('xyxtrimyyx', 'xy')`}, - {`SELECT TRIM(from 'xyxtrimyyx')`, - `SELECT btrim('xyxtrimyyx')`}, - {`SELECT TRIM(both 'xyxtrimyyx')`, - `SELECT btrim('xyxtrimyyx')`}, - {`SELECT TRIM(both from 'xyxtrimyyx')`, - `SELECT btrim('xyxtrimyyx')`}, - {`SELECT TRIM(leading 'xy' from 'xyxtrimyyx')`, - `SELECT ltrim('xyxtrimyyx', 'xy')`}, - {`SELECT TRIM(leading from 'xyxtrimyyx')`, - `SELECT ltrim('xyxtrimyyx')`}, - {`SELECT TRIM(leading 'xyxtrimyyx')`, - `SELECT ltrim('xyxtrimyyx')`}, - {`SELECT TRIM(trailing 'xy' from 'xyxtrimyyx')`, - `SELECT rtrim('xyxtrimyyx', 'xy')`}, - {`SELECT TRIM(trailing from 'xyxtrimyyx')`, - `SELECT rtrim('xyxtrimyyx')`}, - {`SELECT TRIM(trailing 'xyxtrimyyx')`, - `SELECT rtrim('xyxtrimyyx')`}, - {`SELECT a IS NAN`, - `SELECT a = 'NaN'`}, - {`SELECT a IS NOT NAN`, - `SELECT a != 'NaN'`}, - - {`SELECT a FROM generate_series(1, 32)`, - `SELECT a FROM ROWS FROM (generate_series(1, 32))`}, - {`SELECT a FROM generate_series(1, 32) AS s (x)`, - `SELECT a FROM ROWS FROM (generate_series(1, 32)) AS s (x)`}, - {`SELECT a FROM generate_series(1, 32) WITH ORDINALITY AS s (x)`, - `SELECT a FROM ROWS FROM (generate_series(1, 32)) WITH ORDINALITY AS s (x)`}, - {`SELECT a FROM LATERAL generate_series(1, 32)`, - `SELECT a FROM LATERAL ROWS FROM (generate_series(1, 32))`}, - - // Tuples - {`SELECT 1 IN (b)`, `SELECT 1 IN (b,)`}, - {`SELECT ROW()`, `SELECT ()`}, - {`SELECT ROW(1)`, `SELECT (1,)`}, - {`SELECT (ROW(1) AS a)`, `SELECT ((1,) AS a)`}, - - {`SELECT 1 ORDER BY 1 FOR UPDATE LIMIT 1`, - `SELECT 1 ORDER BY 1 LIMIT 1 FOR UPDATE`}, - // FOR READ ONLY is ignored, like in Postgres. - {`SELECT 1 FOR READ ONLY`, `SELECT 1`}, - - {`UPDATE ONLY a SET b = 3`, `UPDATE a SET b = 3`}, - {`UPDATE ONLY a * SET b = 3`, `UPDATE a SET b = 3`}, - {`UPDATE a * SET b = 3`, `UPDATE a SET b = 3`}, - - {`DELETE FROM ONLY a WHERE a = b`, `DELETE FROM a WHERE a = b`}, - {`DELETE FROM a * WHERE a = b`, `DELETE FROM a WHERE a = b`}, - {`DELETE FROM ONLY a * WHERE a = b`, `DELETE FROM a WHERE a = b`}, - - {`SHOW CREATE TABLE t`, - `SHOW CREATE t`}, - {`SHOW CREATE VIEW t`, - `SHOW CREATE t`}, - {`SHOW CREATE SEQUENCE t`, - `SHOW CREATE t`}, - {`SHOW INDEX FROM t`, - `SHOW INDEXES FROM t`}, - {`SHOW CONSTRAINT FROM t`, - `SHOW CONSTRAINTS FROM t`}, - {`SHOW KEYS FROM t`, - `SHOW INDEXES FROM t`}, - {`SHOW SESSION barfoo`, `SHOW barfoo`}, - {`SHOW SESSION database`, `SHOW database`}, - {`SHOW SESSION TIME ZONE`, `SHOW timezone`}, - {`SHOW SESSION TIMEZONE`, `SHOW timezone`}, - - {`SHOW ALL ZONE CONFIGURATIONS`, `SHOW ZONE CONFIGURATIONS`}, - - {`SHOW ZONE CONFIGURATION FROM TABLE t PARTITION foo`, - `SHOW ZONE CONFIGURATION FROM PARTITION foo OF TABLE t`}, - {`SHOW ZONE CONFIGURATION FROM INDEX t@idx PARTITION foo`, - `SHOW ZONE CONFIGURATION FROM PARTITION foo OF INDEX t@idx`}, - - {`SHOW ZONE CONFIGURATION FOR RANGE foo`, `SHOW ZONE CONFIGURATION FROM RANGE foo`}, - {`SHOW ZONE CONFIGURATION FOR DATABASE foo`, `SHOW ZONE CONFIGURATION FROM DATABASE foo`}, - {`SHOW ZONE CONFIGURATION FOR TABLE foo`, `SHOW ZONE CONFIGURATION FROM TABLE foo`}, - {`SHOW ZONE CONFIGURATION FOR TABLE foo PARTITION bar`, - `SHOW ZONE CONFIGURATION FROM PARTITION bar OF TABLE foo`}, - {`SHOW ZONE CONFIGURATION FOR PARTITION foo OF TABLE bar`, - `SHOW ZONE CONFIGURATION FROM PARTITION foo OF TABLE bar`}, - {`SHOW ZONE CONFIGURATION FOR INDEX foo`, - `SHOW ZONE CONFIGURATION FROM INDEX foo`}, - {`SHOW ZONE CONFIGURATION FOR INDEX foo PARTITION bar`, - `SHOW ZONE CONFIGURATION FROM PARTITION bar OF INDEX foo`}, - {`SHOW ZONE CONFIGURATION FOR PARTITION foo OF INDEX bar`, - `SHOW ZONE CONFIGURATION FROM PARTITION foo OF INDEX bar`}, - - {`BEGIN`, - `BEGIN TRANSACTION`}, - {`START TRANSACTION`, - `BEGIN TRANSACTION`}, - {`COMMIT`, - `COMMIT TRANSACTION`}, - {`END`, - `COMMIT TRANSACTION`}, - {`BEGIN TRANSACTION PRIORITY LOW, ISOLATION LEVEL SNAPSHOT`, - `BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY LOW`}, - {`SET TRANSACTION PRIORITY NORMAL, ISOLATION LEVEL SERIALIZABLE`, - `SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY NORMAL`}, - {`SET TRANSACTION ISOLATION LEVEL SERIALIZABLE READ WRITE`, - `SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ WRITE`}, - {`SET TRANSACTION ISOLATION LEVEL SNAPSHOT READ ONLY`, - `SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ ONLY`}, - {"SET CLUSTER SETTING a TO 1", "SET CLUSTER SETTING a = 1"}, - {"SET TRACING TO off", "SET TRACING = off"}, - {"RELEASE foo", "RELEASE SAVEPOINT foo"}, - {"RELEASE SAVEPOINT foo", "RELEASE SAVEPOINT foo"}, - {"ROLLBACK", "ROLLBACK TRANSACTION"}, - {"ROLLBACK TRANSACTION", "ROLLBACK TRANSACTION"}, - {"ROLLBACK TO foo", "ROLLBACK TRANSACTION TO SAVEPOINT foo"}, - {"ROLLBACK TO SAVEPOINT foo", "ROLLBACK TRANSACTION TO SAVEPOINT foo"}, - {"ROLLBACK TRANSACTION TO foo", "ROLLBACK TRANSACTION TO SAVEPOINT foo"}, - {"ROLLBACK TRANSACTION TO SAVEPOINT foo", "ROLLBACK TRANSACTION TO SAVEPOINT foo"}, - {"ABORT TRANSACTION", "ROLLBACK TRANSACTION"}, - {"ABORT WORK", "ROLLBACK TRANSACTION"}, - {"ABORT", "ROLLBACK TRANSACTION"}, - {`DEALLOCATE PREPARE a`, - `DEALLOCATE a`}, - {`DEALLOCATE PREPARE ALL`, - `DEALLOCATE ALL`}, - - {`CANCEL JOB a`, `CANCEL JOBS VALUES (a)`}, - {`EXPLAIN CANCEL JOB a`, `EXPLAIN CANCEL JOBS VALUES (a)`}, - {`CANCEL JOBS FOR SCHEDULE a`, `CANCEL JOBS FOR SCHEDULES VALUES (a)`}, - {`EXPLAIN CANCEL JOBS FOR SCHEDULE a`, `EXPLAIN CANCEL JOBS FOR SCHEDULES VALUES (a)`}, - {`RESUME JOB a`, `RESUME JOBS VALUES (a)`}, - {`EXPLAIN RESUME JOB a`, `EXPLAIN RESUME JOBS VALUES (a)`}, - {`RESUME JOBS FOR SCHEDULE a`, `RESUME JOBS FOR SCHEDULES VALUES (a)`}, - {`EXPLAIN RESUME JOBS FOR SCHEDULE a`, `EXPLAIN RESUME JOBS FOR SCHEDULES VALUES (a)`}, - {`PAUSE JOB a`, `PAUSE JOBS VALUES (a)`}, - {`EXPLAIN PAUSE JOB a`, `EXPLAIN PAUSE JOBS VALUES (a)`}, - {`PAUSE JOBS FOR SCHEDULE a`, `PAUSE JOBS FOR SCHEDULES VALUES (a)`}, - {`EXPLAIN PAUSE JOBS FOR SCHEDULE a`, `EXPLAIN PAUSE JOBS FOR SCHEDULES VALUES (a)`}, - {`PAUSE SCHEDULE a`, `PAUSE SCHEDULES VALUES (a)`}, - {`EXPLAIN PAUSE SCHEDULE a`, `EXPLAIN PAUSE SCHEDULES VALUES (a)`}, - {`RESUME SCHEDULE a`, `RESUME SCHEDULES VALUES (a)`}, - {`EXPLAIN RESUME SCHEDULE a`, `EXPLAIN RESUME SCHEDULES VALUES (a)`}, - {`DROP SCHEDULE a`, `DROP SCHEDULES VALUES (a)`}, - {`EXPLAIN DROP SCHEDULE a`, `EXPLAIN DROP SCHEDULES VALUES (a)`}, - {`SHOW JOB a`, `SHOW JOBS VALUES (a)`}, - {`EXPLAIN SHOW JOB a`, `EXPLAIN SHOW JOBS VALUES (a)`}, - {`SHOW JOBS FOR SCHEDULE a`, `SHOW JOBS FOR SCHEDULES VALUES (a)`}, - {`EXPLAIN SHOW JOBS FOR SCHEDULE a`, `EXPLAIN SHOW JOBS FOR SCHEDULES VALUES (a)`}, - - {`SHOW JOB WHEN COMPLETE a`, `SHOW JOBS WHEN COMPLETE VALUES (a)`}, - {`EXPLAIN SHOW JOB WHEN COMPLETE a`, `EXPLAIN SHOW JOBS WHEN COMPLETE VALUES (a)`}, - {`CANCEL QUERY a`, `CANCEL QUERIES VALUES (a)`}, - {`CANCEL QUERY IF EXISTS a`, `CANCEL QUERIES IF EXISTS VALUES (a)`}, - {`CANCEL SESSION a`, `CANCEL SESSIONS VALUES (a)`}, - {`CANCEL SESSION IF EXISTS a`, `CANCEL SESSIONS IF EXISTS VALUES (a)`}, - - {`BACKUP DATABASE foo TO bar`, - `BACKUP DATABASE foo TO 'bar'`}, - {`BACKUP DATABASE foo TO "bar.12" INCREMENTAL FROM "baz.34"`, - `BACKUP DATABASE foo TO 'bar.12' INCREMENTAL FROM 'baz.34'`}, - {`RESTORE DATABASE foo FROM bar`, - `RESTORE DATABASE foo FROM 'bar'`}, - {`BACKUP DATABASE foo TO ($1)`, `BACKUP DATABASE foo TO $1`}, - - {`RESTORE DATABASE foo FROM ($1)`, `RESTORE DATABASE foo FROM $1`}, - {`RESTORE DATABASE foo FROM ($1), ($2)`, `RESTORE DATABASE foo FROM $1, $2`}, - {`RESTORE DATABASE foo FROM ($1), ($2, $3)`, `RESTORE DATABASE foo FROM $1, ($2, $3)`}, - - {`CREATE CHANGEFEED FOR TABLE foo INTO sink`, - `CREATE CHANGEFEED FOR TABLE foo INTO 'sink'`}, - - {`SHOW CLUSTER SETTING ALL`, `SHOW ALL CLUSTER SETTINGS`}, - {`SHOW CLUSTER SETTINGS`, `SHOW PUBLIC CLUSTER SETTINGS`}, - - {`SHOW SESSIONS`, `SHOW CLUSTER SESSIONS`}, - {`SHOW ALL SESSIONS`, `SHOW ALL CLUSTER SESSIONS`}, - {`SHOW TRANSACTIONS`, `SHOW CLUSTER TRANSACTIONS`}, - {`SHOW ALL TRANSACTIONS`, `SHOW ALL CLUSTER TRANSACTIONS`}, - {`SHOW QUERIES`, `SHOW CLUSTER STATEMENTS`}, - {`SHOW STATEMENTS`, `SHOW CLUSTER STATEMENTS`}, - {`SHOW ALL QUERIES`, `SHOW ALL CLUSTER STATEMENTS`}, - {`SHOW ALL STATEMENTS`, `SHOW ALL CLUSTER STATEMENTS`}, - - {`USE foo`, `SET database = foo`}, - - {`SET NAMES foo`, `SET client_encoding = foo`}, - {`SET NAMES 'foo'`, `SET client_encoding = 'foo'`}, - {`SET NAMES DEFAULT`, `SET client_encoding = DEFAULT`}, - {`SET NAMES`, `SET client_encoding = DEFAULT`}, - - {`SHOW NAMES`, `SHOW client_encoding`}, - - {`SHOW TRANSACTION ISOLATION LEVEL`, `SHOW transaction_isolation`}, - {`SHOW TRANSACTION PRIORITY`, `SHOW transaction_priority`}, - - {`RESET a`, `SET a = DEFAULT`}, - {`RESET CLUSTER SETTING a`, `SET CLUSTER SETTING a = DEFAULT`}, - - {`RESET NAMES`, `SET client_encoding = DEFAULT`}, - - {`CREATE USER foo`, - `CREATE USER 'foo'`}, - {`CREATE USER IF NOT EXISTS foo`, - `CREATE USER IF NOT EXISTS 'foo'`}, - {`CREATE USER foo PASSWORD bar`, - `CREATE USER 'foo' WITH PASSWORD 'bar'`}, - {`CREATE USER foo PASSWORD NULL`, - `CREATE USER 'foo' WITH PASSWORD NULL`}, - {`CREATE USER foo LOGIN VALID UNTIL NULL PASSWORD NULL`, - `CREATE USER 'foo' WITH LOGIN VALID UNTIL NULL PASSWORD NULL`}, - {`CREATE USER foo VALID UNTIL '1970-01-01'`, - `CREATE USER 'foo' WITH VALID UNTIL '1970-01-01'`}, - {`DROP USER foo, bar`, - `DROP USER 'foo', 'bar'`}, - {`DROP USER IF EXISTS foo, bar`, - `DROP USER IF EXISTS 'foo', 'bar'`}, - {`ALTER USER foo PASSWORD bar`, - `ALTER USER 'foo' WITH PASSWORD 'bar'`}, - {`ALTER USER foo WITH PASSWORD bar`, - `ALTER USER 'foo' WITH PASSWORD 'bar'`}, - {`ALTER USER foo WITH PASSWORD NULL`, - `ALTER USER 'foo' WITH PASSWORD NULL`}, - - {`ALTER TABLE a RENAME b TO c`, - `ALTER TABLE a RENAME COLUMN b TO c`}, - - {`COPY t (a, b, c) FROM STDIN BINARY`, - `COPY t (a, b, c) FROM STDIN WITH BINARY`}, - {`COPY t (a, b, c) FROM STDIN destination = 'filename' BINARY`, - `COPY t (a, b, c) FROM STDIN WITH BINARY destination = 'filename'`}, - {`COPY t (a, b, c) FROM STDIN destination = 'filename' CSV DELIMITER ' '`, - `COPY t (a, b, c) FROM STDIN WITH CSV DELIMITER ' ' destination = 'filename'`}, - - // Identifier handling for zone configs. - - {`ALTER TABLE t CONFIGURE ZONE = NULL`, - `ALTER TABLE t CONFIGURE ZONE DISCARD`}, - {`ALTER RANGE default CONFIGURE ZONE USING foo.bar = yay`, - `ALTER RANGE default CONFIGURE ZONE USING "foo.bar" = yay`}, - {`ALTER RANGE meta CONFIGURE ZONE USING foo.bar = yay`, - `ALTER RANGE meta CONFIGURE ZONE USING "foo.bar" = yay`}, - {`ALTER DATABASE db CONFIGURE ZONE USING foo.bar = yay`, - `ALTER DATABASE db CONFIGURE ZONE USING "foo.bar" = yay`}, - {`ALTER TABLE db.t CONFIGURE ZONE USING foo.bar = yay`, - `ALTER TABLE db.t CONFIGURE ZONE USING "foo.bar" = yay`}, - {`ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE USING foo.bar = yay`, - `ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE USING "foo.bar" = yay`}, - {`ALTER TABLE t CONFIGURE ZONE USING foo.bar = yay`, - `ALTER TABLE t CONFIGURE ZONE USING "foo.bar" = yay`}, - {`ALTER PARTITION p OF TABLE t CONFIGURE ZONE USING foo.bar = yay`, - `ALTER PARTITION p OF TABLE t CONFIGURE ZONE USING "foo.bar" = yay`}, - {`ALTER INDEX db.t@i CONFIGURE ZONE USING foo.bar = yay`, - `ALTER INDEX db.t@i CONFIGURE ZONE USING "foo.bar" = yay`}, - {`ALTER INDEX t@i CONFIGURE ZONE USING foo.bar = yay`, - `ALTER INDEX t@i CONFIGURE ZONE USING "foo.bar" = yay`}, - {`ALTER INDEX i CONFIGURE ZONE USING foo.bar = yay`, - `ALTER INDEX i CONFIGURE ZONE USING "foo.bar" = yay`}, - {`ALTER INDEX i CONFIGURE ZONE USING foo = COPY FROM PARENT`, - `ALTER INDEX i CONFIGURE ZONE USING foo = COPY FROM PARENT`}, - { - `ALTER TABLE a SET LOCALITY REGIONAL BY TABLE`, - `ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION`, - }, - { - `ALTER TABLE a SET LOCALITY REGIONAL`, - `ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION`, - }, - { - `ALTER TABLE a SET LOCALITY REGIONAL IN PRIMARY REGION`, - `ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION`, - }, - { - `ALTER TABLE a SET LOCALITY REGIONAL IN "us-west-1"`, - `ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN "us-west-1"`, - }, + ref := stmts.String() + note := "" + if ref != d.Input { + note = " -- normalized!" + } - // Alternative forms for table patterns. - - {`SHOW GRANTS ON foo`, - `SHOW GRANTS ON TABLE foo`}, - {`SHOW GRANTS ON foo, db.foo`, - `SHOW GRANTS ON TABLE foo, db.foo`}, - {`BACKUP foo TO 'bar'`, - `BACKUP TABLE foo TO 'bar'`}, - {`BACKUP foo.foo, baz.baz TO 'bar'`, - `BACKUP TABLE foo.foo, baz.baz TO 'bar'`}, - {`BACKUP foo TO 'bar' AS OF SYSTEM TIME '1' INCREMENTAL FROM 'baz'`, - `BACKUP TABLE foo TO 'bar' AS OF SYSTEM TIME '1' INCREMENTAL FROM 'baz'`}, - {`BACKUP foo TO $1 INCREMENTAL FROM 'bar', $2, 'baz'`, - `BACKUP TABLE foo TO $1 INCREMENTAL FROM 'bar', $2, 'baz'`}, - {`BACKUP TO 'bar'`, - `BACKUP TO 'bar'`}, - // Tables named "role" are handled specially to support SHOW GRANTS ON ROLE, - // but that special handling should not impact BACKUP. - {`BACKUP role TO 'bar'`, - `BACKUP TABLE role TO 'bar'`}, - {`RESTORE foo FROM 'bar'`, - `RESTORE TABLE foo FROM 'bar'`}, - {`RESTORE foo FROM $1`, - `RESTORE TABLE foo FROM $1`}, - {`RESTORE foo FROM $1, $2, 'bar'`, - `RESTORE TABLE foo FROM $1, $2, 'bar'`}, - {`RESTORE FROM $1, $2, 'bar'`, - `RESTORE FROM $1, $2, 'bar'`}, - {`RESTORE foo, baz FROM 'bar'`, - `RESTORE TABLE foo, baz FROM 'bar'`}, - {`RESTORE foo, baz FROM 'bar' AS OF SYSTEM TIME '1'`, - `RESTORE TABLE foo, baz FROM 'bar' AS OF SYSTEM TIME '1'`}, - {`BACKUP foo TO 'bar' WITH ENCRYPTION_PASSPHRASE = 'secret', revision_history`, - `BACKUP TABLE foo TO 'bar' WITH revision_history, encryption_passphrase='secret'`}, - {`BACKUP foo TO 'bar' WITH KMS = 'foo', revision_history`, - `BACKUP TABLE foo TO 'bar' WITH revision_history, kms='foo'`}, - {`BACKUP foo TO 'bar' WITH KMS = ('foo', 'bar'), revision_history`, - `BACKUP TABLE foo TO 'bar' WITH revision_history, kms=('foo', 'bar')`}, - {`BACKUP foo TO 'bar' WITH OPTIONS (detached, ENCRYPTION_PASSPHRASE = 'secret', revision_history)`, - `BACKUP TABLE foo TO 'bar' WITH revision_history, encryption_passphrase='secret', detached`}, - {`BACKUP foo TO 'bar' WITH OPTIONS (detached, KMS = ('foo', 'bar'), revision_history)`, - `BACKUP TABLE foo TO 'bar' WITH revision_history, detached, kms=('foo', 'bar')`}, - - {`RESTORE foo FROM 'bar' WITH OPTIONS (encryption_passphrase='secret', into_db='baz', -skip_missing_foreign_keys, skip_missing_sequences, skip_missing_sequence_owners, skip_missing_views, detached)`, - `RESTORE TABLE foo FROM 'bar' WITH encryption_passphrase='secret', into_db='baz', skip_missing_foreign_keys, skip_missing_sequence_owners, skip_missing_sequences, skip_missing_views, detached`}, - {`RESTORE foo FROM 'bar' WITH ENCRYPTION_PASSPHRASE = 'secret', INTO_DB=baz, -SKIP_MISSING_FOREIGN_KEYS, SKIP_MISSING_SEQUENCES, SKIP_MISSING_SEQUENCE_OWNERS, SKIP_MISSING_VIEWS`, - `RESTORE TABLE foo FROM 'bar' WITH encryption_passphrase='secret', into_db='baz', skip_missing_foreign_keys, skip_missing_sequence_owners, skip_missing_sequences, skip_missing_views`}, - - {`CREATE CHANGEFEED FOR foo INTO 'sink'`, `CREATE CHANGEFEED FOR TABLE foo INTO 'sink'`}, - - {`GRANT SELECT ON foo TO root`, - `GRANT SELECT ON TABLE foo TO root`}, - {`GRANT SELECT, DELETE, UPDATE ON foo, db.foo TO root, bar`, - `GRANT SELECT, DELETE, UPDATE ON TABLE foo, db.foo TO root, bar`}, - // Tables named "role" are handled specially to support SHOW GRANTS ON ROLE, - // but that special handling should not impact GRANT. - {`GRANT SELECT ON role TO root`, - `GRANT SELECT ON TABLE role TO root`}, - {`REVOKE SELECT ON foo FROM root`, - `REVOKE SELECT ON TABLE foo FROM root`}, - {`REVOKE UPDATE, DELETE ON foo, db.foo FROM root, bar`, - `REVOKE UPDATE, DELETE ON TABLE foo, db.foo FROM root, bar`}, - - // RBAC-related statements. - - {`CREATE ROLE foo`, - `CREATE ROLE 'foo'`}, - {`CREATE ROLE IF NOT EXISTS foo`, - `CREATE ROLE IF NOT EXISTS 'foo'`}, - {`CREATE ROLE foo WITH CREATEDB`, - `CREATE ROLE 'foo' WITH CREATEDB`}, - {`CREATE ROLE IF NOT EXISTS foo WITH CREATEDB`, - `CREATE ROLE IF NOT EXISTS 'foo' WITH CREATEDB`}, - {`CREATE ROLE foo CREATEDB`, - `CREATE ROLE 'foo' WITH CREATEDB`}, - {`CREATE ROLE IF NOT EXISTS foo CREATEDB`, - `CREATE ROLE IF NOT EXISTS 'foo' WITH CREATEDB`}, - {`ALTER ROLE foo WITH CREATEDB`, - `ALTER ROLE 'foo' WITH CREATEDB`}, - {`ALTER ROLE foo CREATEDB`, - `ALTER ROLE 'foo' WITH CREATEDB`}, - {`CREATE ROLE foo WITH CREATEROLE`, - `CREATE ROLE 'foo' WITH CREATEROLE`}, - {`CREATE ROLE IF NOT EXISTS foo WITH CREATEROLE`, - `CREATE ROLE IF NOT EXISTS 'foo' WITH CREATEROLE`}, - {`CREATE ROLE foo CREATEROLE`, - `CREATE ROLE 'foo' WITH CREATEROLE`}, - {`CREATE ROLE IF NOT EXISTS foo CREATEROLE`, - `CREATE ROLE IF NOT EXISTS 'foo' WITH CREATEROLE`}, - {`ALTER ROLE foo WITH CREATEROLE`, - `ALTER ROLE 'foo' WITH CREATEROLE`}, - {`ALTER ROLE foo CREATEROLE`, - `ALTER ROLE 'foo' WITH CREATEROLE`}, - {`ALTER ROLE foo CREATELOGIN`, - `ALTER ROLE 'foo' WITH CREATELOGIN`}, - {`ALTER ROLE foo NOCREATELOGIN`, - `ALTER ROLE 'foo' WITH NOCREATELOGIN`}, - {`DROP ROLE foo, bar`, - `DROP ROLE 'foo', 'bar'`}, - {`DROP ROLE IF EXISTS foo, bar`, - `DROP ROLE IF EXISTS 'foo', 'bar'`}, - - // Backward-compat, deprecated IMPORT syntax - {`IMPORT PGDUMP ('nodelocal://0/foo/bar') WITH temp = 'path/to/temp'`, - `IMPORT PGDUMP 'nodelocal://0/foo/bar' WITH temp = 'path/to/temp'`, - }, - {`IMPORT TABLE foo FROM PGDUMPCREATE ('nodelocal://0/foo/bar') WITH temp = 'path/to/temp'`, - `IMPORT TABLE foo FROM PGDUMPCREATE 'nodelocal://0/foo/bar' WITH temp = 'path/to/temp'`, - }, + // Check roundtrip and formatting with flags. + var buf bytes.Buffer + fmt.Fprintf(&buf, "%s%s\n", ref, note) + fmt.Fprintln(&buf, stmts.StringWithFlags(tree.FmtAlwaysGroupExprs), "-- fully parenthetized") + constantsHidden := stmts.StringWithFlags(tree.FmtHideConstants) + fmt.Fprintln(&buf, constantsHidden, "-- literals removed") + + // As of this writing, the SQL statement stats proceed as follows: + // first the literals are removed from statement to form a stat key, + // then the stat key is re-parsed, to undergo the anonymization stage. + // We also want to check the re-parsing is fine. + // + // TODO(knz,rafiss): Turn the following two cases into proper test + // errors once the bugs are fixed. + reparsedStmts, err := parser.Parse(constantsHidden) + if err != nil { + fmt.Fprintln(&buf, "REPARSE WITHOUT LITERALS FAILS:", err) + } else { + reparsedStmtsS := reparsedStmts.String() + if reparsedStmtsS != constantsHidden { + fmt.Fprintln(&buf, reparsedStmtsS, "-- UNEXPECTED REPARSED AST WITHOUT LITERALS") + } + } - // Clarify the ambiguity between "ON ROLE" (RBAC) and "ON ROLE" - // (regular table named "role"). - {`SHOW GRANTS ON role`, `SHOW GRANTS ON ROLE`}, - {`SHOW GRANTS ON "role"`, `SHOW GRANTS ON TABLE role`}, - {`SHOW GRANTS ON role foo`, `SHOW GRANTS ON ROLE foo`}, - {`SHOW GRANTS ON role, foo`, `SHOW GRANTS ON TABLE role, foo`}, - {`SHOW GRANTS ON role foo, bar`, `SHOW GRANTS ON ROLE foo, bar`}, - {`SHOW GRANTS ON "role", foo`, `SHOW GRANTS ON TABLE role, foo`}, - {`SHOW GRANTS ON "role".foo`, `SHOW GRANTS ON TABLE role.foo`}, - {`SHOW GRANTS ON role.foo`, `SHOW GRANTS ON TABLE role.foo`}, - {`SHOW GRANTS ON role.*`, `SHOW GRANTS ON TABLE role.*`}, - - // Foreign Keys - { - `CREATE TABLE a (b INT8, c INT8 REFERENCES foo MATCH SIMPLE)`, - `CREATE TABLE a (b INT8, c INT8 REFERENCES foo)`, - }, - { - `CREATE TABLE a (b INT8, c INT8 REFERENCES foo MATCH SIMPLE ON UPDATE RESTRICT)`, - `CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE RESTRICT)`, - }, - { - `CREATE TABLE a (b INT8, c INT8 REFERENCES foo (bar) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION)`, - `CREATE TABLE a (b INT8, c INT8 REFERENCES foo (bar))`, - }, - { - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE NO ACTION ON DELETE NO ACTION)`, - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other)`, - }, - { - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE RESTRICT ON DELETE RESTRICT)`, - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT ON UPDATE RESTRICT)`, - }, - { - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE RESTRICT ON DELETE NO ACTION)`, - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE RESTRICT)`, - }, - { - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE NO ACTION ON DELETE RESTRICT)`, - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT)`, - }, - { - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE CASCADE ON DELETE CASCADE)`, - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE ON UPDATE CASCADE)`, - }, - { - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE CASCADE ON DELETE NO ACTION)`, - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE CASCADE)`, - }, - { - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE NO ACTION ON DELETE CASCADE)`, - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE)`, - }, - { - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE SET NULL ON DELETE SET NULL)`, - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL ON UPDATE SET NULL)`, - }, - { - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE SET NULL ON DELETE NO ACTION)`, - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE SET NULL)`, - }, - { - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE NO ACTION ON DELETE SET NULL)`, - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL)`, - }, - { - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE SET DEFAULT ON DELETE SET DEFAULT)`, - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT ON UPDATE SET DEFAULT)`, - }, - { - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE SET DEFAULT ON DELETE NO ACTION)`, - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE SET DEFAULT)`, - }, - { - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE NO ACTION ON DELETE SET DEFAULT)`, - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT)`, - }, - { - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE RESTRICT ON DELETE CASCADE)`, - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE ON UPDATE RESTRICT)`, - }, - { - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE CASCADE ON DELETE SET NULL)`, - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL ON UPDATE CASCADE)`, - }, - { - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE SET NULL ON DELETE SET DEFAULT)`, - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT ON UPDATE SET NULL)`, - }, - { - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE SET DEFAULT ON DELETE RESTRICT)`, - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT ON UPDATE SET DEFAULT)`, - }, - { - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other MATCH FULL ON UPDATE NO ACTION ON DELETE NO ACTION)`, - `CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other MATCH FULL)`, - }, - { - `CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH SIMPLE)`, - `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 SIMPLE ON UPDATE SET NULL)`, - `CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) ON UPDATE SET NULL)`, - }, - { - `CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH SIMPLE ON DELETE SET DEFAULT)`, - `CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) ON DELETE SET DEFAULT)`, - }, - { - `CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other MATCH SIMPLE ON DELETE SET DEFAULT ON UPDATE 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 MATCH SIMPLE ON DELETE RESTRICT 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 MATCH SIMPLE ON DELETE SET DEFAULT ON UPDATE CASCADE)`, - `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 MATCH SIMPLE ON DELETE CASCADE ON UPDATE SET NULL)`, - `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 MATCH SIMPLE ON DELETE SET NULL ON UPDATE RESTRICT)`, - `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, c) REFERENCES other MATCH SIMPLE)`, - `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) MATCH SIMPLE)`, - `CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y))`, - }, - { - `CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH SIMPLE ON UPDATE CASCADE)`, - `CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) ON UPDATE CASCADE)`, - }, - { - `CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH SIMPLE ON DELETE CASCADE)`, - `CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) ON DELETE CASCADE)`, - }, - { - `CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH SIMPLE ON DELETE CASCADE ON UPDATE SET NULL)`, - `CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) ON DELETE CASCADE ON UPDATE SET NULL)`, - }, - {`CREATE TABLE a (b INT8 GENERATED ALWAYS AS (a + b) STORED)`, `CREATE TABLE a (b INT8 AS (a + b) STORED)`}, - {`CREATE TABLE a (b INT8 GENERATED ALWAYS AS (a + b) VIRTUAL)`, `CREATE TABLE a (b INT8 AS (a + b) VIRTUAL)`}, - - {`ALTER TABLE a ALTER b DROP STORED`, `ALTER TABLE a ALTER COLUMN b DROP STORED`}, - {`ALTER TABLE a ADD b INT8`, `ALTER TABLE a ADD COLUMN b INT8`}, - {`ALTER TABLE a ADD IF NOT EXISTS b INT8`, `ALTER TABLE a ADD COLUMN IF NOT EXISTS b INT8`}, - {`ALTER TABLE a ADD b INT8 FAMILY fam_a`, `ALTER TABLE a ADD COLUMN b INT8 FAMILY fam_a`}, - {`ALTER TABLE a DROP b`, `ALTER TABLE a DROP COLUMN b`}, - {`ALTER TABLE a ALTER b DROP NOT NULL`, `ALTER TABLE a ALTER COLUMN b DROP NOT NULL`}, - {`ALTER TABLE a ALTER b TYPE INT8`, `ALTER TABLE a ALTER COLUMN b SET DATA TYPE INT8`}, - - {`EXPLAIN ANALYZE (PLAN) SELECT 1`, `EXPLAIN ANALYZE SELECT 1`}, - // Check the alternate spelling. - {`EXPLAIN ANALYSE SELECT 1`, `EXPLAIN ANALYZE SELECT 1`}, - {`EXPLAIN ANALYSE (PLAN) SELECT 1`, `EXPLAIN ANALYZE SELECT 1`}, - {`EXPLAIN (VERBOSE, OPT) SELECT 1`, `EXPLAIN (OPT, VERBOSE) SELECT 1`}, - - {`SET a = INDEX`, `SET a = "index"`}, - {`SET a = NOTHING`, `SET a = "nothing"`}, - - // Regression for #31589 - {`CREATE TABLE FAMILY (x INT)`, - `CREATE TABLE "family" (x INT8)`}, - {`CREATE TABLE INDEX (x INT)`, - `CREATE TABLE "index" (x INT8)`}, - {`CREATE TABLE NOTHING (x INT)`, - `CREATE TABLE "nothing" (x INT8)`}, - - // Ensure MINVALUE/MAXVALUE are not reserved. - {`CREATE TABLE MINVALUE (x INT)`, - `CREATE TABLE minvalue (x INT8)`}, - {`CREATE TABLE MAXVALUE (x INT)`, - `CREATE TABLE maxvalue (x INT8)`}, - {`CREATE TABLE foo (MINVALUE INT)`, - `CREATE TABLE foo (minvalue INT8)`}, - {`CREATE TABLE foo (MAXVALUE INT)`, - `CREATE TABLE foo (maxvalue INT8)`}, - - {`CREATE TABLE a (b INT) PARTITION BY RANGE (b) (PARTITION p1 VALUES FROM (MINVALUE) TO (1), PARTITION p2 VALUES FROM (2, MAXVALUE) TO (4, 4), PARTITION p3 VALUES FROM (4, 4) TO (MAXVALUE))`, - `CREATE TABLE a (b INT8) PARTITION BY RANGE (b) (PARTITION p1 VALUES FROM (minvalue) TO (1), PARTITION p2 VALUES FROM (2, maxvalue) TO (4, 4), PARTITION p3 VALUES FROM (4, 4) TO (maxvalue))`}, - {`CREATE TABLE a (b INT) PARTITION ALL BY RANGE (b) (PARTITION p1 VALUES FROM (MINVALUE) TO (1), PARTITION p2 VALUES FROM (2, MAXVALUE) TO (4, 4), PARTITION p3 VALUES FROM (4, 4) TO (MAXVALUE))`, - `CREATE TABLE a (b INT8) PARTITION ALL BY RANGE (b) (PARTITION p1 VALUES FROM (minvalue) TO (1), PARTITION p2 VALUES FROM (2, maxvalue) TO (4, 4), PARTITION p3 VALUES FROM (4, 4) TO (maxvalue))`}, - - // Check that JSONB operators have higher precedence than '='. - {`SELECT '{}'::JSONB ? 'a' = false`, `SELECT ('{}'::JSONB ? 'a') = false`}, - {`SELECT '{}'::JSONB ?| 'a' = false`, `SELECT ('{}'::JSONB ?| 'a') = false`}, - {`SELECT '{}'::JSONB ?& 'a' = false`, `SELECT ('{}'::JSONB ?& 'a') = false`}, - {`SELECT '{}'::JSONB @> '{}'::JSONB = false`, `SELECT ('{}'::JSONB @> '{}'::JSONB) = false`}, - {`SELECT '{}'::JSONB <@ '{}'::JSONB = false`, `SELECT ('{}'::JSONB <@ '{}'::JSONB) = false`}, - - {`SELECT 1::db.int4.typ array [1]`, `SELECT 1::db.int4.typ[]`}, - {`SELECT 1::int4.typ array [1]`, `SELECT 1::int4.typ[]`}, - {`SELECT 1::db.int4.typ array`, `SELECT 1::db.int4.typ[]`}, - {`CREATE TABLE t (x int4.type array [1])`, `CREATE TABLE t (x int4.type[])`}, - - {`ALTER TYPE t OWNER TO CURRENT_USER`, `ALTER TYPE t OWNER TO "current_user"`}, - {`ALTER TYPE t OWNER TO SESSION_USER`, `ALTER TYPE t OWNER TO "session_user"`}, - - {`REASSIGN OWNED BY CURRENT_USER TO foo`, `REASSIGN OWNED BY "current_user" TO foo`}, - {`REASSIGN OWNED BY SESSION_USER TO foo`, `REASSIGN OWNED BY "session_user" TO foo`}, - {`DROP OWNED BY CURRENT_USER`, `DROP OWNED BY "current_user"`}, - {`DROP OWNED BY SESSION_USER`, `DROP OWNED BY "session_user"`}, - - // Validate that GRANT and REVOKE can accept optional PRIVILEGES syntax - {`GRANT ALL PRIVILEGES ON DATABASE foo TO root`, `GRANT ALL ON DATABASE foo TO root`}, - {`GRANT ALL PRIVILEGES ON TABLE foo TO root`, `GRANT ALL ON TABLE foo TO root`}, - {`GRANT ALL PRIVILEGES ON SCHEMA foo TO root`, `GRANT ALL ON SCHEMA foo TO root`}, - {`GRANT ALL PRIVILEGES ON SCHEMA foo.bar TO root`, `GRANT ALL ON SCHEMA foo.bar TO root`}, - {`GRANT ALL PRIVILEGES ON SCHEMA a.b, c.d TO root`, `GRANT ALL ON SCHEMA a.b, c.d TO root`}, - {`REVOKE ALL PRIVILEGES ON DATABASE foo FROM root`, `REVOKE ALL ON DATABASE foo FROM root`}, - {`REVOKE ALL PRIVILEGES ON TABLE foo FROM root`, `REVOKE ALL ON TABLE foo FROM root`}, - {`REVOKE ALL PRIVILEGES ON SCHEMA foo FROM root`, `REVOKE ALL ON SCHEMA foo FROM root`}, - {`REVOKE ALL PRIVILEGES ON SCHEMA foo.bar FROM root`, `REVOKE ALL ON SCHEMA foo.bar FROM root`}, - {`REVOKE ALL PRIVILEGES ON SCHEMA a.b, c.d FROM root`, `REVOKE ALL ON SCHEMA a.b, c.d FROM root`}, - - // Check rules for normalizing collation names. - {`CREATE TABLE a (b STRING COLLATE "en-us")`, `CREATE TABLE a (b STRING COLLATE en_US)`}, - {`CREATE TABLE a (b STRING COLLATE en_us)`, `CREATE TABLE a (b STRING COLLATE en_US)`}, + fmt.Fprintln(&buf, stmts.StringWithFlags(tree.FmtAnonymize), "-- identifiers removed") + if strings.Contains(ref, tree.PasswordSubstitution) { + fmt.Fprintln(&buf, stmts.StringWithFlags(tree.FmtShowPasswords), "-- passwords exposed") + } - { - `CREATE TABLE a (a INT4) LOCALITY REGIONAL BY TABLE`, - `CREATE TABLE a (a INT4) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION`, - }, - { - `CREATE REPLICATION STREAM FOR a,b,c INTO 'sink' WITH DETACHED, CURSOR='start'`, - `CREATE REPLICATION STREAM FOR TABLE a, b, c INTO 'sink' WITH CURSOR='start', DETACHED`, - }, - } - for _, d := range testData { - t.Run(d.sql, func(t *testing.T) { - stmts, err := parser.Parse(d.sql) - if err != nil { - t.Errorf("%s: expected success, but found %s", d.sql, err) - return - } - s := stmts.StringWithFlags(tree.FmtShowPasswords) - if d.expected != s { - t.Errorf("%s: expected %s, but found (%d statements): %s", d.sql, d.expected, len(stmts), s) - } - if _, err := parser.Parse(s); err != nil { - t.Errorf("expected string found, but not parsable: %s:\n%s", err, s) + return buf.String() } - sqlutils.VerifyStatementPrettyRoundtrip(t, d.expected) + d.Fatalf(t, "unsupported command: %s", d.Cmd) + return "" }) - } + }) } // TestParseTree checks that the implicit grouping done by the grammar @@ -2946,28 +145,26 @@ func TestParseSyntax(t *testing.T) { } } -func TestParseDatadriven(t *testing.T) { - datadriven.Walk(t, "testdata", func(t *testing.T, path string) { - datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string { - switch d.Cmd { - case "error": - _, err := parser.Parse(d.Input) - if err == nil { - return "" - } - pgerr := pgerror.Flatten(err) - msg := pgerr.Message - if pgerr.Detail != "" { - msg += "\nDETAIL: " + pgerr.Detail - } - if pgerr.Hint != "" { - msg += "\nHINT: " + pgerr.Hint - } - return msg +func TestParseErrors(t *testing.T) { + datadriven.RunTest(t, "testdata/errors", func(t *testing.T, d *datadriven.TestData) string { + switch d.Cmd { + case "error": + _, err := parser.Parse(d.Input) + if err == nil { + return "" } - d.Fatalf(t, "unsupported command: %s", d.Cmd) - return "" - }) + pgerr := pgerror.Flatten(err) + msg := pgerr.Message + if pgerr.Detail != "" { + msg += "\nDETAIL: " + pgerr.Detail + } + if pgerr.Hint != "" { + msg += "\nHINT: " + pgerr.Hint + } + return msg + } + d.Fatalf(t, "unsupported command: %s", d.Cmd) + return "" }) } @@ -3197,12 +394,9 @@ func TestUnimplementedSyntax(t *testing.T) { {`ALTER TABLE a ADD CONSTRAINT foo EXCLUDE USING gist (bar WITH =)`, 46657, `add constraint exclude using`, ``}, {`ALTER TABLE a INHERITS b`, 22456, `alter table inherits`, ``}, {`ALTER TABLE a NO INHERITS b`, 22456, `alter table no inherits`, ``}, - {`ALTER FUNCTION public.isnumeric(text) OWNER TO bob`, 0, `alter function`, ``}, {`CREATE ACCESS METHOD a`, 0, `create access method`, ``}, - {`COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'`, 0, `comment on extension`, ``}, - {`COPY x FROM STDIN WHERE a = b`, 54580, ``, ``}, {`CREATE AGGREGATE a`, 0, `create aggregate`, ``}, @@ -3210,7 +404,6 @@ func TestUnimplementedSyntax(t *testing.T) { {`CREATE CONSTRAINT TRIGGER a`, 28296, `create constraint`, ``}, {`CREATE CONVERSION a`, 0, `create conversion`, ``}, {`CREATE DEFAULT CONVERSION a`, 0, `create def conv`, ``}, - {`CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog`, 0, `create extension if not exists with`, ``}, {`CREATE FOREIGN DATA WRAPPER a`, 0, `create fdw`, ``}, {`CREATE FOREIGN TABLE a`, 0, `create foreign table`, ``}, {`CREATE FUNCTION a`, 17511, `create`, ``}, @@ -3249,9 +442,6 @@ func TestUnimplementedSyntax(t *testing.T) { {`DISCARD TEMP`, 0, `discard temp`, ``}, {`DISCARD TEMPORARY`, 0, `discard temp`, ``}, - {`GRANT ALL ON SEQUENCE`, 0, `grant privileges on sequence`, ``}, - {`REVOKE ALL ON SEQUENCE`, 0, `revoke privileges on sequence`, ``}, - {`SET CONSTRAINTS foo`, 0, `set constraints`, ``}, {`SET LOCAL foo = bar`, 32562, ``, ``}, {`SET foo FROM CURRENT`, 0, `set from current`, ``}, diff --git a/pkg/sql/parser/sql.y b/pkg/sql/parser/sql.y index 4e7f1b5de6d0..15d6490dc96e 100644 --- a/pkg/sql/parser/sql.y +++ b/pkg/sql/parser/sql.y @@ -10793,7 +10793,7 @@ d_expr: } | '(' a_expr ')' '.' unrestricted_name { - $$.val = &tree.ColumnAccessExpr{Expr: $2.expr(), ColName: $5 } + $$.val = &tree.ColumnAccessExpr{Expr: $2.expr(), ColName: tree.Name($5) } } | '(' a_expr ')' '.' '@' ICONST { diff --git a/pkg/sql/parser/testdata/parse/alter_database b/pkg/sql/parser/testdata/parse/alter_database new file mode 100644 index 000000000000..06f2fdeea505 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/alter_database @@ -0,0 +1,104 @@ +parse +ALTER DATABASE a RENAME TO b +---- +ALTER DATABASE a RENAME TO b +ALTER DATABASE a RENAME TO b -- fully parenthetized +ALTER DATABASE a RENAME TO b -- literals removed +ALTER DATABASE _ RENAME TO _ -- identifiers removed + +parse +ALTER DATABASE a ADD REGION "us-west-1" +---- +ALTER DATABASE a ADD REGION "us-west-1" +ALTER DATABASE a ADD REGION "us-west-1" -- fully parenthetized +ALTER DATABASE a ADD REGION "us-west-1" -- literals removed +ALTER DATABASE _ ADD REGION _ -- identifiers removed + +parse +ALTER DATABASE a DROP REGION "us-west-1" +---- +ALTER DATABASE a DROP REGION "us-west-1" +ALTER DATABASE a DROP REGION "us-west-1" -- fully parenthetized +ALTER DATABASE a DROP REGION "us-west-1" -- literals removed +ALTER DATABASE _ DROP REGION _ -- identifiers removed + +parse +ALTER DATABASE a SURVIVE REGION FAILURE +---- +ALTER DATABASE a SURVIVE REGION FAILURE +ALTER DATABASE a SURVIVE REGION FAILURE -- fully parenthetized +ALTER DATABASE a SURVIVE REGION FAILURE -- literals removed +ALTER DATABASE _ SURVIVE REGION FAILURE -- identifiers removed + +parse +ALTER DATABASE a PRIMARY REGION "us-west-3" +---- +ALTER DATABASE a PRIMARY REGION "us-west-3" +ALTER DATABASE a PRIMARY REGION "us-west-3" -- fully parenthetized +ALTER DATABASE a PRIMARY REGION "us-west-3" -- literals removed +ALTER DATABASE _ PRIMARY REGION _ -- identifiers removed + +parse +EXPLAIN ALTER DATABASE a RENAME TO b +---- +EXPLAIN ALTER DATABASE a RENAME TO b +EXPLAIN ALTER DATABASE a RENAME TO b -- fully parenthetized +EXPLAIN ALTER DATABASE a RENAME TO b -- literals removed +EXPLAIN ALTER DATABASE _ RENAME TO _ -- identifiers removed + +parse +ALTER DATABASE a OWNER TO foo +---- +ALTER DATABASE a OWNER TO foo +ALTER DATABASE a OWNER TO foo -- fully parenthetized +ALTER DATABASE a OWNER TO foo -- literals removed +ALTER DATABASE _ OWNER TO _ -- identifiers removed + +parse +ALTER DATABASE db CONFIGURE ZONE = 'foo' +---- +ALTER DATABASE db CONFIGURE ZONE = 'foo' +ALTER DATABASE db CONFIGURE ZONE = ('foo') -- fully parenthetized +ALTER DATABASE db CONFIGURE ZONE = _ -- literals removed +ALTER DATABASE _ CONFIGURE ZONE = 'foo' -- identifiers removed + +parse +EXPLAIN ALTER DATABASE db CONFIGURE ZONE = 'foo' +---- +EXPLAIN ALTER DATABASE db CONFIGURE ZONE = 'foo' +EXPLAIN ALTER DATABASE db CONFIGURE ZONE = ('foo') -- fully parenthetized +EXPLAIN ALTER DATABASE db CONFIGURE ZONE = _ -- literals removed +EXPLAIN ALTER DATABASE _ CONFIGURE ZONE = 'foo' -- identifiers removed + +parse +ALTER DATABASE db CONFIGURE ZONE USING foo = bar, baz = yay +---- +ALTER DATABASE db CONFIGURE ZONE USING foo = bar, baz = yay +ALTER DATABASE db CONFIGURE ZONE USING foo = (bar), baz = (yay) -- fully parenthetized +ALTER DATABASE db CONFIGURE ZONE USING foo = bar, baz = yay -- literals removed +ALTER DATABASE _ CONFIGURE ZONE USING _ = _, _ = _ -- identifiers removed + +parse +ALTER DATABASE db CONFIGURE ZONE USING foo.bar = yay +---- +ALTER DATABASE db CONFIGURE ZONE USING "foo.bar" = yay -- normalized! +ALTER DATABASE db CONFIGURE ZONE USING "foo.bar" = (yay) -- fully parenthetized +ALTER DATABASE db CONFIGURE ZONE USING "foo.bar" = yay -- literals removed +ALTER DATABASE _ CONFIGURE ZONE USING _ = _ -- identifiers removed + +parse +ALTER DATABASE db CONFIGURE ZONE DISCARD +---- +ALTER DATABASE db CONFIGURE ZONE DISCARD +ALTER DATABASE db CONFIGURE ZONE DISCARD -- fully parenthetized +ALTER DATABASE db CONFIGURE ZONE DISCARD -- literals removed +ALTER DATABASE _ CONFIGURE ZONE DISCARD -- identifiers removed + + +parse +ALTER DATABASE db CONFIGURE ZONE USING DEFAULT +---- +ALTER DATABASE db CONFIGURE ZONE USING DEFAULT +ALTER DATABASE db CONFIGURE ZONE USING DEFAULT -- fully parenthetized +ALTER DATABASE db CONFIGURE ZONE USING DEFAULT -- literals removed +ALTER DATABASE _ CONFIGURE ZONE USING DEFAULT -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/alter_index b/pkg/sql/parser/testdata/parse/alter_index new file mode 100644 index 000000000000..c5f0cf7774d6 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/alter_index @@ -0,0 +1,361 @@ +parse +ALTER INDEX b RENAME TO b +---- +ALTER INDEX b RENAME TO b +ALTER INDEX b RENAME TO b -- fully parenthetized +ALTER INDEX b RENAME TO b -- literals removed +ALTER INDEX _ RENAME TO _ -- identifiers removed + +parse +EXPLAIN ALTER INDEX b RENAME TO b +---- +EXPLAIN ALTER INDEX b RENAME TO b +EXPLAIN ALTER INDEX b RENAME TO b -- fully parenthetized +EXPLAIN ALTER INDEX b RENAME TO b -- literals removed +EXPLAIN ALTER INDEX _ RENAME TO _ -- identifiers removed + +parse +ALTER INDEX a@b RENAME TO b +---- +ALTER INDEX a@b RENAME TO b +ALTER INDEX a@b RENAME TO b -- fully parenthetized +ALTER INDEX a@b RENAME TO b -- literals removed +ALTER INDEX _@_ RENAME TO _ -- identifiers removed + +parse +ALTER INDEX a@primary RENAME TO like +---- +ALTER INDEX a@primary RENAME TO like +ALTER INDEX a@primary RENAME TO like -- fully parenthetized +ALTER INDEX a@primary RENAME TO like -- literals removed +ALTER INDEX _@_ RENAME TO _ -- identifiers removed + +parse +ALTER INDEX IF EXISTS b RENAME TO b +---- +ALTER INDEX IF EXISTS b RENAME TO b +ALTER INDEX IF EXISTS b RENAME TO b -- fully parenthetized +ALTER INDEX IF EXISTS b RENAME TO b -- literals removed +ALTER INDEX IF EXISTS _ RENAME TO _ -- identifiers removed + +parse +ALTER INDEX IF EXISTS a@b RENAME TO b +---- +ALTER INDEX IF EXISTS a@b RENAME TO b +ALTER INDEX IF EXISTS a@b RENAME TO b -- fully parenthetized +ALTER INDEX IF EXISTS a@b RENAME TO b -- literals removed +ALTER INDEX IF EXISTS _@_ RENAME TO _ -- identifiers removed + +parse +ALTER INDEX IF EXISTS a@primary RENAME TO like +---- +ALTER INDEX IF EXISTS a@primary RENAME TO like +ALTER INDEX IF EXISTS a@primary RENAME TO like -- fully parenthetized +ALTER INDEX IF EXISTS a@primary RENAME TO like -- literals removed +ALTER INDEX IF EXISTS _@_ RENAME TO _ -- identifiers removed + +parse +ALTER INDEX a@i SPLIT AT VALUES (1) +---- +ALTER INDEX a@i SPLIT AT VALUES (1) +ALTER INDEX a@i SPLIT AT VALUES ((1)) -- fully parenthetized +ALTER INDEX a@i SPLIT AT VALUES (_) -- literals removed +ALTER INDEX _@_ SPLIT AT VALUES (1) -- identifiers removed + +parse +ALTER INDEX d.a@i SPLIT AT VALUES (2) +---- +ALTER INDEX d.a@i SPLIT AT VALUES (2) +ALTER INDEX d.a@i SPLIT AT VALUES ((2)) -- fully parenthetized +ALTER INDEX d.a@i SPLIT AT VALUES (_) -- literals removed +ALTER INDEX _._@_ SPLIT AT VALUES (2) -- identifiers removed + +parse +ALTER INDEX i SPLIT AT VALUES (1) +---- +ALTER INDEX i SPLIT AT VALUES (1) +ALTER INDEX i SPLIT AT VALUES ((1)) -- fully parenthetized +ALTER INDEX i SPLIT AT VALUES (_) -- literals removed +ALTER INDEX _ SPLIT AT VALUES (1) -- identifiers removed + +parse +ALTER INDEX d.i SPLIT AT VALUES (2) +---- +ALTER INDEX d.i SPLIT AT VALUES (2) +ALTER INDEX d.i SPLIT AT VALUES ((2)) -- fully parenthetized +ALTER INDEX d.i SPLIT AT VALUES (_) -- literals removed +ALTER INDEX _._ SPLIT AT VALUES (2) -- identifiers removed + +parse +ALTER INDEX "primary" SPLIT AT VALUES (2) +---- +ALTER INDEX "primary" SPLIT AT VALUES (2) +ALTER INDEX "primary" SPLIT AT VALUES ((2)) -- fully parenthetized +ALTER INDEX "primary" SPLIT AT VALUES (_) -- literals removed +ALTER INDEX _ SPLIT AT VALUES (2) -- identifiers removed + +parse +ALTER INDEX public.public."primary" SPLIT AT VALUES (2) +---- +ALTER INDEX public.public."primary" SPLIT AT VALUES (2) +ALTER INDEX public.public."primary" SPLIT AT VALUES ((2)) -- fully parenthetized +ALTER INDEX public.public."primary" SPLIT AT VALUES (_) -- literals removed +ALTER INDEX _._._ SPLIT AT VALUES (2) -- identifiers removed + +parse +ALTER INDEX a@i UNSPLIT AT VALUES (1) +---- +ALTER INDEX a@i UNSPLIT AT VALUES (1) +ALTER INDEX a@i UNSPLIT AT VALUES ((1)) -- fully parenthetized +ALTER INDEX a@i UNSPLIT AT VALUES (_) -- literals removed +ALTER INDEX _@_ UNSPLIT AT VALUES (1) -- identifiers removed + +parse +ALTER INDEX d.a@i UNSPLIT AT VALUES (2) +---- +ALTER INDEX d.a@i UNSPLIT AT VALUES (2) +ALTER INDEX d.a@i UNSPLIT AT VALUES ((2)) -- fully parenthetized +ALTER INDEX d.a@i UNSPLIT AT VALUES (_) -- literals removed +ALTER INDEX _._@_ UNSPLIT AT VALUES (2) -- identifiers removed + +parse +ALTER INDEX i UNSPLIT AT VALUES (1) +---- +ALTER INDEX i UNSPLIT AT VALUES (1) +ALTER INDEX i UNSPLIT AT VALUES ((1)) -- fully parenthetized +ALTER INDEX i UNSPLIT AT VALUES (_) -- literals removed +ALTER INDEX _ UNSPLIT AT VALUES (1) -- identifiers removed + +parse +ALTER INDEX d.i UNSPLIT AT VALUES (2) +---- +ALTER INDEX d.i UNSPLIT AT VALUES (2) +ALTER INDEX d.i UNSPLIT AT VALUES ((2)) -- fully parenthetized +ALTER INDEX d.i UNSPLIT AT VALUES (_) -- literals removed +ALTER INDEX _._ UNSPLIT AT VALUES (2) -- identifiers removed + +parse +ALTER INDEX "primary" UNSPLIT AT VALUES (2) +---- +ALTER INDEX "primary" UNSPLIT AT VALUES (2) +ALTER INDEX "primary" UNSPLIT AT VALUES ((2)) -- fully parenthetized +ALTER INDEX "primary" UNSPLIT AT VALUES (_) -- literals removed +ALTER INDEX _ UNSPLIT AT VALUES (2) -- identifiers removed + +parse +ALTER INDEX public.public."primary" UNSPLIT AT VALUES (2) +---- +ALTER INDEX public.public."primary" UNSPLIT AT VALUES (2) +ALTER INDEX public.public."primary" UNSPLIT AT VALUES ((2)) -- fully parenthetized +ALTER INDEX public.public."primary" UNSPLIT AT VALUES (_) -- literals removed +ALTER INDEX _._._ UNSPLIT AT VALUES (2) -- identifiers removed + +parse +ALTER INDEX d.i EXPERIMENTAL_RELOCATE VALUES (ARRAY[1], 2) +---- +ALTER INDEX d.i EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[1], 2) -- normalized! +ALTER INDEX d.i EXPERIMENTAL_RELOCATE VOTERS VALUES ((ARRAY[(1)]), (2)) -- fully parenthetized +ALTER INDEX d.i EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[_], _) -- literals removed +ALTER INDEX _._ EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[1], 2) -- identifiers removed + +parse +ALTER INDEX d.i EXPERIMENTAL_RELOCATE LEASE VALUES (1, 2) +---- +ALTER INDEX d.i EXPERIMENTAL_RELOCATE LEASE VALUES (1, 2) +ALTER INDEX d.i EXPERIMENTAL_RELOCATE LEASE VALUES ((1), (2)) -- fully parenthetized +ALTER INDEX d.i EXPERIMENTAL_RELOCATE LEASE VALUES (_, _) -- literals removed +ALTER INDEX _._ EXPERIMENTAL_RELOCATE LEASE VALUES (1, 2) -- identifiers removed + +parse +ALTER INDEX d.i SCATTER FROM (1) TO (2) +---- +ALTER INDEX d.i SCATTER FROM (1) TO (2) +ALTER INDEX d.i SCATTER FROM ((1)) TO ((2)) -- fully parenthetized +ALTER INDEX d.i SCATTER FROM (_) TO (_) -- literals removed +ALTER INDEX _._ SCATTER FROM (1) TO (2) -- identifiers removed + +parse +ALTER INDEX i CONFIGURE ZONE = 'foo' +---- +ALTER INDEX i CONFIGURE ZONE = 'foo' +ALTER INDEX i CONFIGURE ZONE = ('foo') -- fully parenthetized +ALTER INDEX i CONFIGURE ZONE = _ -- literals removed +ALTER INDEX _ CONFIGURE ZONE = 'foo' -- identifiers removed + +parse +EXPLAIN ALTER INDEX i CONFIGURE ZONE = 'foo' +---- +EXPLAIN ALTER INDEX i CONFIGURE ZONE = 'foo' +EXPLAIN ALTER INDEX i CONFIGURE ZONE = ('foo') -- fully parenthetized +EXPLAIN ALTER INDEX i CONFIGURE ZONE = _ -- literals removed +EXPLAIN ALTER INDEX _ CONFIGURE ZONE = 'foo' -- identifiers removed + +parse +ALTER INDEX db.t@i CONFIGURE ZONE = 'foo' +---- +ALTER INDEX db.t@i CONFIGURE ZONE = 'foo' +ALTER INDEX db.t@i CONFIGURE ZONE = ('foo') -- fully parenthetized +ALTER INDEX db.t@i CONFIGURE ZONE = _ -- literals removed +ALTER INDEX _._@_ CONFIGURE ZONE = 'foo' -- identifiers removed + +parse +ALTER INDEX t@i CONFIGURE ZONE = 'foo' +---- +ALTER INDEX t@i CONFIGURE ZONE = 'foo' +ALTER INDEX t@i CONFIGURE ZONE = ('foo') -- fully parenthetized +ALTER INDEX t@i CONFIGURE ZONE = _ -- literals removed +ALTER INDEX _@_ CONFIGURE ZONE = 'foo' -- identifiers removed + +parse +ALTER PARTITION p OF INDEX db.t@idx CONFIGURE ZONE = 'foo' +---- +ALTER PARTITION p OF INDEX db.t@idx CONFIGURE ZONE = 'foo' +ALTER PARTITION p OF INDEX db.t@idx CONFIGURE ZONE = ('foo') -- fully parenthetized +ALTER PARTITION p OF INDEX db.t@idx CONFIGURE ZONE = _ -- literals removed +ALTER PARTITION _ OF INDEX _._@_ CONFIGURE ZONE = 'foo' -- identifiers removed + +parse +EXPLAIN ALTER PARTITION p OF INDEX db.t@idx CONFIGURE ZONE = 'foo' +---- +EXPLAIN ALTER PARTITION p OF INDEX db.t@idx CONFIGURE ZONE = 'foo' +EXPLAIN ALTER PARTITION p OF INDEX db.t@idx CONFIGURE ZONE = ('foo') -- fully parenthetized +EXPLAIN ALTER PARTITION p OF INDEX db.t@idx CONFIGURE ZONE = _ -- literals removed +EXPLAIN ALTER PARTITION _ OF INDEX _._@_ CONFIGURE ZONE = 'foo' -- identifiers removed + +parse +ALTER INDEX db.t@i CONFIGURE ZONE USING foo = bar, baz = yay +---- +ALTER INDEX db.t@i CONFIGURE ZONE USING foo = bar, baz = yay +ALTER INDEX db.t@i CONFIGURE ZONE USING foo = (bar), baz = (yay) -- fully parenthetized +ALTER INDEX db.t@i CONFIGURE ZONE USING foo = bar, baz = yay -- literals removed +ALTER INDEX _._@_ CONFIGURE ZONE USING _ = _, _ = _ -- identifiers removed + +parse +ALTER INDEX t@i CONFIGURE ZONE USING foo = bar, baz = yay +---- +ALTER INDEX t@i CONFIGURE ZONE USING foo = bar, baz = yay +ALTER INDEX t@i CONFIGURE ZONE USING foo = (bar), baz = (yay) -- fully parenthetized +ALTER INDEX t@i CONFIGURE ZONE USING foo = bar, baz = yay -- literals removed +ALTER INDEX _@_ CONFIGURE ZONE USING _ = _, _ = _ -- identifiers removed + +parse +ALTER INDEX i CONFIGURE ZONE USING foo = bar, baz = yay +---- +ALTER INDEX i CONFIGURE ZONE USING foo = bar, baz = yay +ALTER INDEX i CONFIGURE ZONE USING foo = (bar), baz = (yay) -- fully parenthetized +ALTER INDEX i CONFIGURE ZONE USING foo = bar, baz = yay -- literals removed +ALTER INDEX _ CONFIGURE ZONE USING _ = _, _ = _ -- identifiers removed + +parse +ALTER INDEX i CONFIGURE ZONE USING foo = COPY FROM PARENT +---- +ALTER INDEX i CONFIGURE ZONE USING foo = COPY FROM PARENT +ALTER INDEX i CONFIGURE ZONE USING foo = COPY FROM PARENT -- fully parenthetized +ALTER INDEX i CONFIGURE ZONE USING foo = COPY FROM PARENT -- literals removed +ALTER INDEX _ CONFIGURE ZONE USING _ = COPY FROM PARENT -- identifiers removed + +parse +ALTER INDEX i CONFIGURE ZONE USING foo = COPY FROM PARENT +---- +ALTER INDEX i CONFIGURE ZONE USING foo = COPY FROM PARENT +ALTER INDEX i CONFIGURE ZONE USING foo = COPY FROM PARENT -- fully parenthetized +ALTER INDEX i CONFIGURE ZONE USING foo = COPY FROM PARENT -- literals removed +ALTER INDEX _ CONFIGURE ZONE USING _ = COPY FROM PARENT -- identifiers removed + +parse +ALTER INDEX i CONFIGURE ZONE USING foo = bar, baz = COPY FROM PARENT +---- +ALTER INDEX i CONFIGURE ZONE USING foo = bar, baz = COPY FROM PARENT +ALTER INDEX i CONFIGURE ZONE USING foo = (bar), baz = COPY FROM PARENT -- fully parenthetized +ALTER INDEX i CONFIGURE ZONE USING foo = bar, baz = COPY FROM PARENT -- literals removed +ALTER INDEX _ CONFIGURE ZONE USING _ = _, _ = COPY FROM PARENT -- identifiers removed + +parse +ALTER INDEX i CONFIGURE ZONE USING foo = COPY FROM PARENT, baz = COPY FROM PARENT +---- +ALTER INDEX i CONFIGURE ZONE USING foo = COPY FROM PARENT, baz = COPY FROM PARENT +ALTER INDEX i CONFIGURE ZONE USING foo = COPY FROM PARENT, baz = COPY FROM PARENT -- fully parenthetized +ALTER INDEX i CONFIGURE ZONE USING foo = COPY FROM PARENT, baz = COPY FROM PARENT -- literals removed +ALTER INDEX _ CONFIGURE ZONE USING _ = COPY FROM PARENT, _ = COPY FROM PARENT -- identifiers removed + +parse +ALTER INDEX i CONFIGURE ZONE USING foo = bar, other = COPY FROM PARENT, baz = yay +---- +ALTER INDEX i CONFIGURE ZONE USING foo = bar, other = COPY FROM PARENT, baz = yay +ALTER INDEX i CONFIGURE ZONE USING foo = (bar), other = COPY FROM PARENT, baz = (yay) -- fully parenthetized +ALTER INDEX i CONFIGURE ZONE USING foo = bar, other = COPY FROM PARENT, baz = yay -- literals removed +ALTER INDEX _ CONFIGURE ZONE USING _ = _, _ = COPY FROM PARENT, _ = _ -- identifiers removed + +parse +ALTER INDEX db.t@i CONFIGURE ZONE USING foo.bar = yay +---- +ALTER INDEX db.t@i CONFIGURE ZONE USING "foo.bar" = yay -- normalized! +ALTER INDEX db.t@i CONFIGURE ZONE USING "foo.bar" = (yay) -- fully parenthetized +ALTER INDEX db.t@i CONFIGURE ZONE USING "foo.bar" = yay -- literals removed +ALTER INDEX _._@_ CONFIGURE ZONE USING _ = _ -- identifiers removed + +parse +ALTER INDEX t@i CONFIGURE ZONE USING foo.bar = yay +---- +ALTER INDEX t@i CONFIGURE ZONE USING "foo.bar" = yay -- normalized! +ALTER INDEX t@i CONFIGURE ZONE USING "foo.bar" = (yay) -- fully parenthetized +ALTER INDEX t@i CONFIGURE ZONE USING "foo.bar" = yay -- literals removed +ALTER INDEX _@_ CONFIGURE ZONE USING _ = _ -- identifiers removed + +parse +ALTER INDEX i CONFIGURE ZONE USING foo.bar = yay +---- +ALTER INDEX i CONFIGURE ZONE USING "foo.bar" = yay -- normalized! +ALTER INDEX i CONFIGURE ZONE USING "foo.bar" = (yay) -- fully parenthetized +ALTER INDEX i CONFIGURE ZONE USING "foo.bar" = yay -- literals removed +ALTER INDEX _ CONFIGURE ZONE USING _ = _ -- identifiers removed + + +parse +ALTER INDEX db.t@i CONFIGURE ZONE DISCARD +---- +ALTER INDEX db.t@i CONFIGURE ZONE DISCARD +ALTER INDEX db.t@i CONFIGURE ZONE DISCARD -- fully parenthetized +ALTER INDEX db.t@i CONFIGURE ZONE DISCARD -- literals removed +ALTER INDEX _._@_ CONFIGURE ZONE DISCARD -- identifiers removed + +parse +ALTER INDEX t@i CONFIGURE ZONE DISCARD +---- +ALTER INDEX t@i CONFIGURE ZONE DISCARD +ALTER INDEX t@i CONFIGURE ZONE DISCARD -- fully parenthetized +ALTER INDEX t@i CONFIGURE ZONE DISCARD -- literals removed +ALTER INDEX _@_ CONFIGURE ZONE DISCARD -- identifiers removed + +parse +ALTER INDEX i CONFIGURE ZONE DISCARD +---- +ALTER INDEX i CONFIGURE ZONE DISCARD +ALTER INDEX i CONFIGURE ZONE DISCARD -- fully parenthetized +ALTER INDEX i CONFIGURE ZONE DISCARD -- literals removed +ALTER INDEX _ CONFIGURE ZONE DISCARD -- identifiers removed + + +parse +ALTER INDEX db.t@i CONFIGURE ZONE USING DEFAULT +---- +ALTER INDEX db.t@i CONFIGURE ZONE USING DEFAULT +ALTER INDEX db.t@i CONFIGURE ZONE USING DEFAULT -- fully parenthetized +ALTER INDEX db.t@i CONFIGURE ZONE USING DEFAULT -- literals removed +ALTER INDEX _._@_ CONFIGURE ZONE USING DEFAULT -- identifiers removed + +parse +ALTER INDEX t@i CONFIGURE ZONE USING DEFAULT +---- +ALTER INDEX t@i CONFIGURE ZONE USING DEFAULT +ALTER INDEX t@i CONFIGURE ZONE USING DEFAULT -- fully parenthetized +ALTER INDEX t@i CONFIGURE ZONE USING DEFAULT -- literals removed +ALTER INDEX _@_ CONFIGURE ZONE USING DEFAULT -- identifiers removed + +parse +ALTER INDEX i CONFIGURE ZONE USING DEFAULT +---- +ALTER INDEX i CONFIGURE ZONE USING DEFAULT +ALTER INDEX i CONFIGURE ZONE USING DEFAULT -- fully parenthetized +ALTER INDEX i CONFIGURE ZONE USING DEFAULT -- literals removed +ALTER INDEX _ CONFIGURE ZONE USING DEFAULT -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/alter_range b/pkg/sql/parser/testdata/parse/alter_range new file mode 100644 index 000000000000..f0476f1d1b90 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/alter_range @@ -0,0 +1,87 @@ +parse +ALTER RANGE default CONFIGURE ZONE = 'foo' +---- +ALTER RANGE default CONFIGURE ZONE = 'foo' +ALTER RANGE default CONFIGURE ZONE = ('foo') -- fully parenthetized +ALTER RANGE default CONFIGURE ZONE = _ -- literals removed +ALTER RANGE _ CONFIGURE ZONE = 'foo' -- identifiers removed + +parse +EXPLAIN ALTER RANGE default CONFIGURE ZONE = 'foo' +---- +EXPLAIN ALTER RANGE default CONFIGURE ZONE = 'foo' +EXPLAIN ALTER RANGE default CONFIGURE ZONE = ('foo') -- fully parenthetized +EXPLAIN ALTER RANGE default CONFIGURE ZONE = _ -- literals removed +EXPLAIN ALTER RANGE _ CONFIGURE ZONE = 'foo' -- identifiers removed + +parse +ALTER RANGE meta CONFIGURE ZONE = 'foo' +---- +ALTER RANGE meta CONFIGURE ZONE = 'foo' +ALTER RANGE meta CONFIGURE ZONE = ('foo') -- fully parenthetized +ALTER RANGE meta CONFIGURE ZONE = _ -- literals removed +ALTER RANGE _ CONFIGURE ZONE = 'foo' -- identifiers removed + +parse +ALTER RANGE default CONFIGURE ZONE USING foo = bar, baz = yay +---- +ALTER RANGE default CONFIGURE ZONE USING foo = bar, baz = yay +ALTER RANGE default CONFIGURE ZONE USING foo = (bar), baz = (yay) -- fully parenthetized +ALTER RANGE default CONFIGURE ZONE USING foo = bar, baz = yay -- literals removed +ALTER RANGE _ CONFIGURE ZONE USING _ = _, _ = _ -- identifiers removed + +parse +ALTER RANGE meta CONFIGURE ZONE USING foo = bar, baz = yay +---- +ALTER RANGE meta CONFIGURE ZONE USING foo = bar, baz = yay +ALTER RANGE meta CONFIGURE ZONE USING foo = (bar), baz = (yay) -- fully parenthetized +ALTER RANGE meta CONFIGURE ZONE USING foo = bar, baz = yay -- literals removed +ALTER RANGE _ CONFIGURE ZONE USING _ = _, _ = _ -- identifiers removed + +parse +ALTER RANGE default CONFIGURE ZONE USING foo.bar = yay +---- +ALTER RANGE default CONFIGURE ZONE USING "foo.bar" = yay -- normalized! +ALTER RANGE default CONFIGURE ZONE USING "foo.bar" = (yay) -- fully parenthetized +ALTER RANGE default CONFIGURE ZONE USING "foo.bar" = yay -- literals removed +ALTER RANGE _ CONFIGURE ZONE USING _ = _ -- identifiers removed + +parse +ALTER RANGE meta CONFIGURE ZONE USING foo.bar = yay +---- +ALTER RANGE meta CONFIGURE ZONE USING "foo.bar" = yay -- normalized! +ALTER RANGE meta CONFIGURE ZONE USING "foo.bar" = (yay) -- fully parenthetized +ALTER RANGE meta CONFIGURE ZONE USING "foo.bar" = yay -- literals removed +ALTER RANGE _ CONFIGURE ZONE USING _ = _ -- identifiers removed + +parse +ALTER RANGE default CONFIGURE ZONE DISCARD +---- +ALTER RANGE default CONFIGURE ZONE DISCARD +ALTER RANGE default CONFIGURE ZONE DISCARD -- fully parenthetized +ALTER RANGE default CONFIGURE ZONE DISCARD -- literals removed +ALTER RANGE _ CONFIGURE ZONE DISCARD -- identifiers removed + +parse +ALTER RANGE meta CONFIGURE ZONE DISCARD +---- +ALTER RANGE meta CONFIGURE ZONE DISCARD +ALTER RANGE meta CONFIGURE ZONE DISCARD -- fully parenthetized +ALTER RANGE meta CONFIGURE ZONE DISCARD -- literals removed +ALTER RANGE _ CONFIGURE ZONE DISCARD -- identifiers removed + +parse +ALTER RANGE default CONFIGURE ZONE USING DEFAULT +---- +ALTER RANGE default CONFIGURE ZONE USING DEFAULT +ALTER RANGE default CONFIGURE ZONE USING DEFAULT -- fully parenthetized +ALTER RANGE default CONFIGURE ZONE USING DEFAULT -- literals removed +ALTER RANGE _ CONFIGURE ZONE USING DEFAULT -- identifiers removed + +parse +ALTER RANGE meta CONFIGURE ZONE USING DEFAULT +---- +ALTER RANGE meta CONFIGURE ZONE USING DEFAULT +ALTER RANGE meta CONFIGURE ZONE USING DEFAULT -- fully parenthetized +ALTER RANGE meta CONFIGURE ZONE USING DEFAULT -- literals removed +ALTER RANGE _ CONFIGURE ZONE USING DEFAULT -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/alter_schema b/pkg/sql/parser/testdata/parse/alter_schema new file mode 100644 index 000000000000..841d1daac505 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/alter_schema @@ -0,0 +1,31 @@ +parse +ALTER SCHEMA s RENAME TO s2 +---- +ALTER SCHEMA s RENAME TO s2 +ALTER SCHEMA s RENAME TO s2 -- fully parenthetized +ALTER SCHEMA s RENAME TO s2 -- literals removed +ALTER SCHEMA _ RENAME TO _ -- identifiers removed + +parse +ALTER SCHEMA s OWNER TO foo +---- +ALTER SCHEMA s OWNER TO foo +ALTER SCHEMA s OWNER TO foo -- fully parenthetized +ALTER SCHEMA s OWNER TO foo -- literals removed +ALTER SCHEMA _ OWNER TO _ -- identifiers removed + +parse +ALTER SCHEMA db.s RENAME TO s2 +---- +ALTER SCHEMA db.s RENAME TO s2 +ALTER SCHEMA db.s RENAME TO s2 -- fully parenthetized +ALTER SCHEMA db.s RENAME TO s2 -- literals removed +ALTER SCHEMA _._ RENAME TO _ -- identifiers removed + +parse +ALTER SCHEMA db.s OWNER TO foo +---- +ALTER SCHEMA db.s OWNER TO foo +ALTER SCHEMA db.s OWNER TO foo -- fully parenthetized +ALTER SCHEMA db.s OWNER TO foo -- literals removed +ALTER SCHEMA _._ OWNER TO _ -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/alter_sequence b/pkg/sql/parser/testdata/parse/alter_sequence new file mode 100644 index 000000000000..20130f87a623 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/alter_sequence @@ -0,0 +1,92 @@ +parse +ALTER SEQUENCE seq SET SCHEMA s +---- +ALTER SEQUENCE seq SET SCHEMA s +ALTER SEQUENCE seq SET SCHEMA s -- fully parenthetized +ALTER SEQUENCE seq SET SCHEMA s -- literals removed +ALTER SEQUENCE _ SET SCHEMA _ -- identifiers removed + +parse +ALTER SEQUENCE IF EXISTS seq SET SCHEMA s +---- +ALTER SEQUENCE IF EXISTS seq SET SCHEMA s +ALTER SEQUENCE IF EXISTS seq SET SCHEMA s -- fully parenthetized +ALTER SEQUENCE IF EXISTS seq SET SCHEMA s -- literals removed +ALTER SEQUENCE IF EXISTS _ SET SCHEMA _ -- identifiers removed + + +parse +ALTER SEQUENCE a RENAME TO b +---- +ALTER SEQUENCE a RENAME TO b +ALTER SEQUENCE a RENAME TO b -- fully parenthetized +ALTER SEQUENCE a RENAME TO b -- literals removed +ALTER SEQUENCE _ RENAME TO _ -- identifiers removed + +parse +EXPLAIN ALTER SEQUENCE a RENAME TO b +---- +EXPLAIN ALTER SEQUENCE a RENAME TO b +EXPLAIN ALTER SEQUENCE a RENAME TO b -- fully parenthetized +EXPLAIN ALTER SEQUENCE a RENAME TO b -- literals removed +EXPLAIN ALTER SEQUENCE _ RENAME TO _ -- identifiers removed + +parse +ALTER SEQUENCE IF EXISTS a RENAME TO b +---- +ALTER SEQUENCE IF EXISTS a RENAME TO b +ALTER SEQUENCE IF EXISTS a RENAME TO b -- fully parenthetized +ALTER SEQUENCE IF EXISTS a RENAME TO b -- literals removed +ALTER SEQUENCE IF EXISTS _ RENAME TO _ -- identifiers removed + +parse +ALTER SEQUENCE a INCREMENT BY 5 START WITH 1000 +---- +ALTER SEQUENCE a INCREMENT BY 5 START WITH 1000 +ALTER SEQUENCE a INCREMENT BY 5 START WITH 1000 -- fully parenthetized +ALTER SEQUENCE a INCREMENT BY _ START WITH _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +ALTER SEQUENCE _ INCREMENT BY 5 START WITH 1000 -- identifiers removed + +parse +EXPLAIN ALTER SEQUENCE a INCREMENT BY 5 START WITH 1000 +---- +EXPLAIN ALTER SEQUENCE a INCREMENT BY 5 START WITH 1000 +EXPLAIN ALTER SEQUENCE a INCREMENT BY 5 START WITH 1000 -- fully parenthetized +EXPLAIN ALTER SEQUENCE a INCREMENT BY _ START WITH _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +EXPLAIN ALTER SEQUENCE _ INCREMENT BY 5 START WITH 1000 -- identifiers removed + +parse +ALTER SEQUENCE IF EXISTS a INCREMENT BY 5 START WITH 1000 +---- +ALTER SEQUENCE IF EXISTS a INCREMENT BY 5 START WITH 1000 +ALTER SEQUENCE IF EXISTS a INCREMENT BY 5 START WITH 1000 -- fully parenthetized +ALTER SEQUENCE IF EXISTS a INCREMENT BY _ START WITH _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +ALTER SEQUENCE IF EXISTS _ INCREMENT BY 5 START WITH 1000 -- identifiers removed + +parse +ALTER SEQUENCE IF EXISTS a NO CYCLE CACHE 1 +---- +ALTER SEQUENCE IF EXISTS a NO CYCLE CACHE 1 +ALTER SEQUENCE IF EXISTS a NO CYCLE CACHE 1 -- fully parenthetized +ALTER SEQUENCE IF EXISTS a NO CYCLE CACHE _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +ALTER SEQUENCE IF EXISTS _ NO CYCLE CACHE 1 -- identifiers removed + +parse +ALTER SEQUENCE a OWNED BY b +---- +ALTER SEQUENCE a OWNED BY b +ALTER SEQUENCE a OWNED BY (b) -- fully parenthetized +ALTER SEQUENCE a OWNED BY b -- literals removed +ALTER SEQUENCE _ OWNED BY _ -- identifiers removed + +parse +ALTER SEQUENCE a OWNED BY NONE +---- +ALTER SEQUENCE a OWNED BY NONE +ALTER SEQUENCE a OWNED BY NONE -- fully parenthetized +ALTER SEQUENCE a OWNED BY NONE -- literals removed +ALTER SEQUENCE _ OWNED BY NONE -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/alter_table b/pkg/sql/parser/testdata/parse/alter_table new file mode 100644 index 000000000000..b536277a4aff --- /dev/null +++ b/pkg/sql/parser/testdata/parse/alter_table @@ -0,0 +1,1044 @@ +parse +ALTER TABLE a RENAME TO b +---- +ALTER TABLE a RENAME TO b +ALTER TABLE a RENAME TO b -- fully parenthetized +ALTER TABLE a RENAME TO b -- literals removed +ALTER TABLE _ RENAME TO _ -- identifiers removed + +parse +EXPLAIN ALTER TABLE a RENAME TO b +---- +EXPLAIN ALTER TABLE a RENAME TO b +EXPLAIN ALTER TABLE a RENAME TO b -- fully parenthetized +EXPLAIN ALTER TABLE a RENAME TO b -- literals removed +EXPLAIN ALTER TABLE _ RENAME TO _ -- identifiers removed + +parse +ALTER TABLE IF EXISTS a RENAME TO b +---- +ALTER TABLE IF EXISTS a RENAME TO b +ALTER TABLE IF EXISTS a RENAME TO b -- fully parenthetized +ALTER TABLE IF EXISTS a RENAME TO b -- literals removed +ALTER TABLE IF EXISTS _ RENAME TO _ -- identifiers removed + +parse +ALTER TABLE a RENAME COLUMN c1 TO c2 +---- +ALTER TABLE a RENAME COLUMN c1 TO c2 +ALTER TABLE a RENAME COLUMN c1 TO c2 -- fully parenthetized +ALTER TABLE a RENAME COLUMN c1 TO c2 -- literals removed +ALTER TABLE _ RENAME COLUMN _ TO _ -- identifiers removed + +parse +ALTER TABLE IF EXISTS a RENAME COLUMN c1 TO c2 +---- +ALTER TABLE IF EXISTS a RENAME COLUMN c1 TO c2 +ALTER TABLE IF EXISTS a RENAME COLUMN c1 TO c2 -- fully parenthetized +ALTER TABLE IF EXISTS a RENAME COLUMN c1 TO c2 -- literals removed +ALTER TABLE IF EXISTS _ RENAME COLUMN _ TO _ -- identifiers removed + +parse +ALTER TABLE a RENAME b TO c +---- +ALTER TABLE a RENAME COLUMN b TO c -- normalized! +ALTER TABLE a RENAME COLUMN b TO c -- fully parenthetized +ALTER TABLE a RENAME COLUMN b TO c -- literals removed +ALTER TABLE _ RENAME COLUMN _ TO _ -- identifiers removed + +parse +ALTER TABLE a RENAME CONSTRAINT c1 TO c2 +---- +ALTER TABLE a RENAME CONSTRAINT c1 TO c2 +ALTER TABLE a RENAME CONSTRAINT c1 TO c2 -- fully parenthetized +ALTER TABLE a RENAME CONSTRAINT c1 TO c2 -- literals removed +ALTER TABLE _ RENAME CONSTRAINT _ TO _ -- identifiers removed + +parse +ALTER TABLE IF EXISTS a RENAME CONSTRAINT c1 TO c2 +---- +ALTER TABLE IF EXISTS a RENAME CONSTRAINT c1 TO c2 +ALTER TABLE IF EXISTS a RENAME CONSTRAINT c1 TO c2 -- fully parenthetized +ALTER TABLE IF EXISTS a RENAME CONSTRAINT c1 TO c2 -- literals removed +ALTER TABLE IF EXISTS _ RENAME CONSTRAINT _ TO _ -- identifiers removed + +parse +ALTER TABLE a RENAME CONSTRAINT c TO d, RENAME COLUMN e TO f +---- +ALTER TABLE a RENAME CONSTRAINT c TO d, RENAME COLUMN e TO f +ALTER TABLE a RENAME CONSTRAINT c TO d, RENAME COLUMN e TO f -- fully parenthetized +ALTER TABLE a RENAME CONSTRAINT c TO d, RENAME COLUMN e TO f -- literals removed +ALTER TABLE _ RENAME CONSTRAINT _ TO _, RENAME COLUMN _ TO _ -- identifiers removed + +parse +ALTER TABLE a SET LOCALITY GLOBAL +---- +ALTER TABLE a SET LOCALITY GLOBAL +ALTER TABLE a SET LOCALITY GLOBAL -- fully parenthetized +ALTER TABLE a SET LOCALITY GLOBAL -- literals removed +ALTER TABLE _ SET LOCALITY GLOBAL -- identifiers removed + + +parse +ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN region_name +---- +ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN region_name +ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN region_name -- fully parenthetized +ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN region_name -- literals removed +ALTER TABLE _ SET LOCALITY REGIONAL BY TABLE IN _ -- identifiers removed + +parse +ALTER TABLE a SET LOCALITY REGIONAL IN "us-west-1" +---- +ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN "us-west-1" -- normalized! +ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN "us-west-1" -- fully parenthetized +ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN "us-west-1" -- literals removed +ALTER TABLE _ SET LOCALITY REGIONAL BY TABLE IN _ -- identifiers removed + +parse +ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION +---- +ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION +ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- fully parenthetized +ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- literals removed +ALTER TABLE _ SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- identifiers removed + +parse +ALTER TABLE a SET LOCALITY REGIONAL BY TABLE +---- +ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- normalized! +ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- fully parenthetized +ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- literals removed +ALTER TABLE _ SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- identifiers removed + +parse +ALTER TABLE a SET LOCALITY REGIONAL +---- +ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- normalized! +ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- fully parenthetized +ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- literals removed +ALTER TABLE _ SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- identifiers removed + +parse +ALTER TABLE a SET LOCALITY REGIONAL IN PRIMARY REGION +---- +ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- normalized! +ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- fully parenthetized +ALTER TABLE a SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- literals removed +ALTER TABLE _ SET LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- identifiers removed + +parse +ALTER TABLE a SET LOCALITY REGIONAL BY ROW +---- +ALTER TABLE a SET LOCALITY REGIONAL BY ROW +ALTER TABLE a SET LOCALITY REGIONAL BY ROW -- fully parenthetized +ALTER TABLE a SET LOCALITY REGIONAL BY ROW -- literals removed +ALTER TABLE _ SET LOCALITY REGIONAL BY ROW -- identifiers removed + +parse +ALTER TABLE a SET LOCALITY REGIONAL BY ROW AS bobby +---- +ALTER TABLE a SET LOCALITY REGIONAL BY ROW AS bobby +ALTER TABLE a SET LOCALITY REGIONAL BY ROW AS bobby -- fully parenthetized +ALTER TABLE a SET LOCALITY REGIONAL BY ROW AS bobby -- literals removed +ALTER TABLE _ SET LOCALITY REGIONAL BY ROW AS _ -- identifiers removed + +parse +ALTER TABLE a ADD COLUMN b INT8, ADD CONSTRAINT a_idx UNIQUE (a) +---- +ALTER TABLE a ADD COLUMN b INT8, ADD CONSTRAINT a_idx UNIQUE (a) +ALTER TABLE a ADD COLUMN b INT8, ADD CONSTRAINT a_idx UNIQUE (a) -- fully parenthetized +ALTER TABLE a ADD COLUMN b INT8, ADD CONSTRAINT a_idx UNIQUE (a) -- literals removed +ALTER TABLE _ ADD COLUMN _ INT8, ADD CONSTRAINT _ UNIQUE (_) -- identifiers removed + +parse +EXPLAIN ALTER TABLE a ADD COLUMN b INT8 +---- +EXPLAIN ALTER TABLE a ADD COLUMN b INT8 +EXPLAIN ALTER TABLE a ADD COLUMN b INT8 -- fully parenthetized +EXPLAIN ALTER TABLE a ADD COLUMN b INT8 -- literals removed +EXPLAIN ALTER TABLE _ ADD COLUMN _ INT8 -- identifiers removed + +parse +ALTER TABLE a ADD b INT8 +---- +ALTER TABLE a ADD COLUMN b INT8 -- normalized! +ALTER TABLE a ADD COLUMN b INT8 -- fully parenthetized +ALTER TABLE a ADD COLUMN b INT8 -- literals removed +ALTER TABLE _ ADD COLUMN _ INT8 -- identifiers removed + +parse +ALTER TABLE a ADD IF NOT EXISTS b INT8 +---- +ALTER TABLE a ADD COLUMN IF NOT EXISTS b INT8 -- normalized! +ALTER TABLE a ADD COLUMN IF NOT EXISTS b INT8 -- fully parenthetized +ALTER TABLE a ADD COLUMN IF NOT EXISTS b INT8 -- literals removed +ALTER TABLE _ ADD COLUMN IF NOT EXISTS _ INT8 -- identifiers removed + +parse +ALTER TABLE a ADD COLUMN IF NOT EXISTS b INT8, ADD CONSTRAINT a_idx UNIQUE (a) +---- +ALTER TABLE a ADD COLUMN IF NOT EXISTS b INT8, ADD CONSTRAINT a_idx UNIQUE (a) +ALTER TABLE a ADD COLUMN IF NOT EXISTS b INT8, ADD CONSTRAINT a_idx UNIQUE (a) -- fully parenthetized +ALTER TABLE a ADD COLUMN IF NOT EXISTS b INT8, ADD CONSTRAINT a_idx UNIQUE (a) -- literals removed +ALTER TABLE _ ADD COLUMN IF NOT EXISTS _ INT8, ADD CONSTRAINT _ UNIQUE (_) -- identifiers removed + +parse +ALTER TABLE IF EXISTS a ADD COLUMN b INT8, ADD CONSTRAINT a_idx UNIQUE (a) +---- +ALTER TABLE IF EXISTS a ADD COLUMN b INT8, ADD CONSTRAINT a_idx UNIQUE (a) +ALTER TABLE IF EXISTS a ADD COLUMN b INT8, ADD CONSTRAINT a_idx UNIQUE (a) -- fully parenthetized +ALTER TABLE IF EXISTS a ADD COLUMN b INT8, ADD CONSTRAINT a_idx UNIQUE (a) -- literals removed +ALTER TABLE IF EXISTS _ ADD COLUMN _ INT8, ADD CONSTRAINT _ UNIQUE (_) -- identifiers removed + +parse +ALTER TABLE IF EXISTS a ADD COLUMN IF NOT EXISTS b INT8, ADD CONSTRAINT a_idx UNIQUE (a) +---- +ALTER TABLE IF EXISTS a ADD COLUMN IF NOT EXISTS b INT8, ADD CONSTRAINT a_idx UNIQUE (a) +ALTER TABLE IF EXISTS a ADD COLUMN IF NOT EXISTS b INT8, ADD CONSTRAINT a_idx UNIQUE (a) -- fully parenthetized +ALTER TABLE IF EXISTS a ADD COLUMN IF NOT EXISTS b INT8, ADD CONSTRAINT a_idx UNIQUE (a) -- literals removed +ALTER TABLE IF EXISTS _ ADD COLUMN IF NOT EXISTS _ INT8, ADD CONSTRAINT _ UNIQUE (_) -- identifiers removed + +parse +ALTER TABLE a ADD COLUMN b INT8 UNIQUE WITHOUT INDEX, ADD CONSTRAINT a_no_idx UNIQUE WITHOUT INDEX (a) +---- +ALTER TABLE a ADD COLUMN b INT8 UNIQUE WITHOUT INDEX, ADD CONSTRAINT a_no_idx UNIQUE WITHOUT INDEX (a) +ALTER TABLE a ADD COLUMN b INT8 UNIQUE WITHOUT INDEX, ADD CONSTRAINT a_no_idx UNIQUE WITHOUT INDEX (a) -- fully parenthetized +ALTER TABLE a ADD COLUMN b INT8 UNIQUE WITHOUT INDEX, ADD CONSTRAINT a_no_idx UNIQUE WITHOUT INDEX (a) -- literals removed +ALTER TABLE _ ADD COLUMN _ INT8 UNIQUE WITHOUT INDEX, ADD CONSTRAINT _ UNIQUE WITHOUT INDEX (_) -- identifiers removed + +parse +ALTER TABLE a ADD COLUMN IF NOT EXISTS b INT8, ADD CONSTRAINT a_idx UNIQUE (a) NOT VALID +---- +ALTER TABLE a ADD COLUMN IF NOT EXISTS b INT8, ADD CONSTRAINT a_idx UNIQUE (a) NOT VALID +ALTER TABLE a ADD COLUMN IF NOT EXISTS b INT8, ADD CONSTRAINT a_idx UNIQUE (a) NOT VALID -- fully parenthetized +ALTER TABLE a ADD COLUMN IF NOT EXISTS b INT8, ADD CONSTRAINT a_idx UNIQUE (a) NOT VALID -- literals removed +ALTER TABLE _ ADD COLUMN IF NOT EXISTS _ INT8, ADD CONSTRAINT _ UNIQUE (_) NOT VALID -- identifiers removed + +parse +ALTER TABLE IF EXISTS a ADD COLUMN b INT8, ADD CONSTRAINT a_idx UNIQUE (a) +---- +ALTER TABLE IF EXISTS a ADD COLUMN b INT8, ADD CONSTRAINT a_idx UNIQUE (a) +ALTER TABLE IF EXISTS a ADD COLUMN b INT8, ADD CONSTRAINT a_idx UNIQUE (a) -- fully parenthetized +ALTER TABLE IF EXISTS a ADD COLUMN b INT8, ADD CONSTRAINT a_idx UNIQUE (a) -- literals removed +ALTER TABLE IF EXISTS _ ADD COLUMN _ INT8, ADD CONSTRAINT _ UNIQUE (_) -- identifiers removed + +parse +ALTER TABLE IF EXISTS a ADD COLUMN IF NOT EXISTS b INT8, ADD CONSTRAINT a_idx UNIQUE (a) +---- +ALTER TABLE IF EXISTS a ADD COLUMN IF NOT EXISTS b INT8, ADD CONSTRAINT a_idx UNIQUE (a) +ALTER TABLE IF EXISTS a ADD COLUMN IF NOT EXISTS b INT8, ADD CONSTRAINT a_idx UNIQUE (a) -- fully parenthetized +ALTER TABLE IF EXISTS a ADD COLUMN IF NOT EXISTS b INT8, ADD CONSTRAINT a_idx UNIQUE (a) -- literals removed +ALTER TABLE IF EXISTS _ ADD COLUMN IF NOT EXISTS _ INT8, ADD CONSTRAINT _ UNIQUE (_) -- identifiers removed + +parse +ALTER TABLE a ADD COLUMN b INT8 FAMILY fam_a +---- +ALTER TABLE a ADD COLUMN b INT8 FAMILY fam_a +ALTER TABLE a ADD COLUMN b INT8 FAMILY fam_a -- fully parenthetized +ALTER TABLE a ADD COLUMN b INT8 FAMILY fam_a -- literals removed +ALTER TABLE _ ADD COLUMN _ INT8 FAMILY _ -- identifiers removed + +parse +ALTER TABLE a ADD b INT8 FAMILY fam_a +---- +ALTER TABLE a ADD COLUMN b INT8 FAMILY fam_a -- normalized! +ALTER TABLE a ADD COLUMN b INT8 FAMILY fam_a -- fully parenthetized +ALTER TABLE a ADD COLUMN b INT8 FAMILY fam_a -- literals removed +ALTER TABLE _ ADD COLUMN _ INT8 FAMILY _ -- identifiers removed + + +parse +ALTER TABLE a ADD COLUMN b INT8 CREATE FAMILY +---- +ALTER TABLE a ADD COLUMN b INT8 CREATE FAMILY +ALTER TABLE a ADD COLUMN b INT8 CREATE FAMILY -- fully parenthetized +ALTER TABLE a ADD COLUMN b INT8 CREATE FAMILY -- literals removed +ALTER TABLE _ ADD COLUMN _ INT8 CREATE FAMILY -- identifiers removed + +parse +ALTER TABLE a ADD COLUMN b INT8 CREATE FAMILY fam_b +---- +ALTER TABLE a ADD COLUMN b INT8 CREATE FAMILY fam_b +ALTER TABLE a ADD COLUMN b INT8 CREATE FAMILY fam_b -- fully parenthetized +ALTER TABLE a ADD COLUMN b INT8 CREATE FAMILY fam_b -- literals removed +ALTER TABLE _ ADD COLUMN _ INT8 CREATE FAMILY _ -- identifiers removed + +parse +ALTER TABLE a ADD COLUMN b INT8 CREATE IF NOT EXISTS FAMILY fam_b +---- +ALTER TABLE a ADD COLUMN b INT8 CREATE IF NOT EXISTS FAMILY fam_b +ALTER TABLE a ADD COLUMN b INT8 CREATE IF NOT EXISTS FAMILY fam_b -- fully parenthetized +ALTER TABLE a ADD COLUMN b INT8 CREATE IF NOT EXISTS FAMILY fam_b -- literals removed +ALTER TABLE _ ADD COLUMN _ INT8 CREATE IF NOT EXISTS FAMILY _ -- identifiers removed + +parse +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a, b, c) +---- +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a, b, c) +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a, b, c) -- fully parenthetized +ALTER TABLE t ALTER PRIMARY KEY USING COLUMNS (a, b, c) -- literals removed +ALTER TABLE _ ALTER PRIMARY KEY USING COLUMNS (_, _, _) -- identifiers removed + +parse +ALTER TABLE a DROP COLUMN b, DROP CONSTRAINT a_idx +---- +ALTER TABLE a DROP COLUMN b, DROP CONSTRAINT a_idx +ALTER TABLE a DROP COLUMN b, DROP CONSTRAINT a_idx -- fully parenthetized +ALTER TABLE a DROP COLUMN b, DROP CONSTRAINT a_idx -- literals removed +ALTER TABLE _ DROP COLUMN _, DROP CONSTRAINT _ -- identifiers removed + +parse +ALTER TABLE a DROP COLUMN IF EXISTS b, DROP CONSTRAINT a_idx +---- +ALTER TABLE a DROP COLUMN IF EXISTS b, DROP CONSTRAINT a_idx +ALTER TABLE a DROP COLUMN IF EXISTS b, DROP CONSTRAINT a_idx -- fully parenthetized +ALTER TABLE a DROP COLUMN IF EXISTS b, DROP CONSTRAINT a_idx -- literals removed +ALTER TABLE _ DROP COLUMN IF EXISTS _, DROP CONSTRAINT _ -- identifiers removed + +parse +ALTER TABLE IF EXISTS a DROP COLUMN b, DROP CONSTRAINT a_idx +---- +ALTER TABLE IF EXISTS a DROP COLUMN b, DROP CONSTRAINT a_idx +ALTER TABLE IF EXISTS a DROP COLUMN b, DROP CONSTRAINT a_idx -- fully parenthetized +ALTER TABLE IF EXISTS a DROP COLUMN b, DROP CONSTRAINT a_idx -- literals removed +ALTER TABLE IF EXISTS _ DROP COLUMN _, DROP CONSTRAINT _ -- identifiers removed + +parse +ALTER TABLE IF EXISTS a DROP COLUMN IF EXISTS b, DROP CONSTRAINT a_idx +---- +ALTER TABLE IF EXISTS a DROP COLUMN IF EXISTS b, DROP CONSTRAINT a_idx +ALTER TABLE IF EXISTS a DROP COLUMN IF EXISTS b, DROP CONSTRAINT a_idx -- fully parenthetized +ALTER TABLE IF EXISTS a DROP COLUMN IF EXISTS b, DROP CONSTRAINT a_idx -- literals removed +ALTER TABLE IF EXISTS _ DROP COLUMN IF EXISTS _, DROP CONSTRAINT _ -- identifiers removed + +parse +ALTER TABLE a DROP COLUMN b, DROP CONSTRAINT a_idx +---- +ALTER TABLE a DROP COLUMN b, DROP CONSTRAINT a_idx +ALTER TABLE a DROP COLUMN b, DROP CONSTRAINT a_idx -- fully parenthetized +ALTER TABLE a DROP COLUMN b, DROP CONSTRAINT a_idx -- literals removed +ALTER TABLE _ DROP COLUMN _, DROP CONSTRAINT _ -- identifiers removed + +parse +ALTER TABLE a DROP COLUMN IF EXISTS b, DROP CONSTRAINT a_idx +---- +ALTER TABLE a DROP COLUMN IF EXISTS b, DROP CONSTRAINT a_idx +ALTER TABLE a DROP COLUMN IF EXISTS b, DROP CONSTRAINT a_idx -- fully parenthetized +ALTER TABLE a DROP COLUMN IF EXISTS b, DROP CONSTRAINT a_idx -- literals removed +ALTER TABLE _ DROP COLUMN IF EXISTS _, DROP CONSTRAINT _ -- identifiers removed + +parse +ALTER TABLE IF EXISTS a DROP COLUMN b, DROP CONSTRAINT a_idx +---- +ALTER TABLE IF EXISTS a DROP COLUMN b, DROP CONSTRAINT a_idx +ALTER TABLE IF EXISTS a DROP COLUMN b, DROP CONSTRAINT a_idx -- fully parenthetized +ALTER TABLE IF EXISTS a DROP COLUMN b, DROP CONSTRAINT a_idx -- literals removed +ALTER TABLE IF EXISTS _ DROP COLUMN _, DROP CONSTRAINT _ -- identifiers removed + +parse +ALTER TABLE IF EXISTS a DROP COLUMN IF EXISTS b, DROP CONSTRAINT a_idx +---- +ALTER TABLE IF EXISTS a DROP COLUMN IF EXISTS b, DROP CONSTRAINT a_idx +ALTER TABLE IF EXISTS a DROP COLUMN IF EXISTS b, DROP CONSTRAINT a_idx -- fully parenthetized +ALTER TABLE IF EXISTS a DROP COLUMN IF EXISTS b, DROP CONSTRAINT a_idx -- literals removed +ALTER TABLE IF EXISTS _ DROP COLUMN IF EXISTS _, DROP CONSTRAINT _ -- identifiers removed + +parse +ALTER TABLE a DROP COLUMN b CASCADE +---- +ALTER TABLE a DROP COLUMN b CASCADE +ALTER TABLE a DROP COLUMN b CASCADE -- fully parenthetized +ALTER TABLE a DROP COLUMN b CASCADE -- literals removed +ALTER TABLE _ DROP COLUMN _ CASCADE -- identifiers removed + +parse +ALTER TABLE a DROP COLUMN b RESTRICT +---- +ALTER TABLE a DROP COLUMN b RESTRICT +ALTER TABLE a DROP COLUMN b RESTRICT -- fully parenthetized +ALTER TABLE a DROP COLUMN b RESTRICT -- literals removed +ALTER TABLE _ DROP COLUMN _ RESTRICT -- identifiers removed + +parse +ALTER TABLE a DROP b +---- +ALTER TABLE a DROP COLUMN b -- normalized! +ALTER TABLE a DROP COLUMN b -- fully parenthetized +ALTER TABLE a DROP COLUMN b -- literals removed +ALTER TABLE _ DROP COLUMN _ -- identifiers removed + +parse +ALTER TABLE a DROP CONSTRAINT b CASCADE +---- +ALTER TABLE a DROP CONSTRAINT b CASCADE +ALTER TABLE a DROP CONSTRAINT b CASCADE -- fully parenthetized +ALTER TABLE a DROP CONSTRAINT b CASCADE -- literals removed +ALTER TABLE _ DROP CONSTRAINT _ CASCADE -- identifiers removed + +parse +ALTER TABLE a DROP CONSTRAINT IF EXISTS b RESTRICT +---- +ALTER TABLE a DROP CONSTRAINT IF EXISTS b RESTRICT +ALTER TABLE a DROP CONSTRAINT IF EXISTS b RESTRICT -- fully parenthetized +ALTER TABLE a DROP CONSTRAINT IF EXISTS b RESTRICT -- literals removed +ALTER TABLE _ DROP CONSTRAINT IF EXISTS _ RESTRICT -- identifiers removed + +parse +ALTER TABLE a VALIDATE CONSTRAINT a +---- +ALTER TABLE a VALIDATE CONSTRAINT a +ALTER TABLE a VALIDATE CONSTRAINT a -- fully parenthetized +ALTER TABLE a VALIDATE CONSTRAINT a -- literals removed +ALTER TABLE _ VALIDATE CONSTRAINT _ -- identifiers removed + +parse +ALTER TABLE a ADD PRIMARY KEY (x, y, z) +---- +ALTER TABLE a ADD PRIMARY KEY (x, y, z) +ALTER TABLE a ADD PRIMARY KEY (x, y, z) -- fully parenthetized +ALTER TABLE a ADD PRIMARY KEY (x, y, z) -- literals removed +ALTER TABLE _ ADD PRIMARY KEY (_, _, _) -- identifiers removed + +parse +ALTER TABLE a ADD PRIMARY KEY (x, y, z) USING HASH WITH BUCKET_COUNT = 10 INTERLEAVE IN PARENT b (x, y) +---- +ALTER TABLE a ADD PRIMARY KEY (x, y, z) USING HASH WITH BUCKET_COUNT = 10 INTERLEAVE IN PARENT b (x, y) +ALTER TABLE a ADD PRIMARY KEY (x, y, z) USING HASH WITH BUCKET_COUNT = (10) INTERLEAVE IN PARENT b (x, y) -- fully parenthetized +ALTER TABLE a ADD PRIMARY KEY (x, y, z) USING HASH WITH BUCKET_COUNT = _ INTERLEAVE IN PARENT b (x, y) -- literals removed +ALTER TABLE _ ADD PRIMARY KEY (_, _, _) USING HASH WITH BUCKET_COUNT = 10 INTERLEAVE IN PARENT _ (_, _) -- identifiers removed + +parse +ALTER TABLE a ADD CONSTRAINT "primary" PRIMARY KEY (x, y, z) +---- +ALTER TABLE a ADD CONSTRAINT "primary" PRIMARY KEY (x, y, z) +ALTER TABLE a ADD CONSTRAINT "primary" PRIMARY KEY (x, y, z) -- fully parenthetized +ALTER TABLE a ADD CONSTRAINT "primary" PRIMARY KEY (x, y, z) -- literals removed +ALTER TABLE _ ADD CONSTRAINT _ PRIMARY KEY (_, _, _) -- identifiers removed + +parse +ALTER TABLE a ADD CONSTRAINT "primary" PRIMARY KEY (x, y, z) USING HASH WITH BUCKET_COUNT = 10 INTERLEAVE IN PARENT b (x, y) +---- +ALTER TABLE a ADD CONSTRAINT "primary" PRIMARY KEY (x, y, z) USING HASH WITH BUCKET_COUNT = 10 INTERLEAVE IN PARENT b (x, y) +ALTER TABLE a ADD CONSTRAINT "primary" PRIMARY KEY (x, y, z) USING HASH WITH BUCKET_COUNT = (10) INTERLEAVE IN PARENT b (x, y) -- fully parenthetized +ALTER TABLE a ADD CONSTRAINT "primary" PRIMARY KEY (x, y, z) USING HASH WITH BUCKET_COUNT = _ INTERLEAVE IN PARENT b (x, y) -- literals removed +ALTER TABLE _ ADD CONSTRAINT _ PRIMARY KEY (_, _, _) USING HASH WITH BUCKET_COUNT = 10 INTERLEAVE IN PARENT _ (_, _) -- identifiers removed + +parse +ALTER TABLE a ALTER COLUMN b SET DEFAULT 42 +---- +ALTER TABLE a ALTER COLUMN b SET DEFAULT 42 +ALTER TABLE a ALTER COLUMN b SET DEFAULT (42) -- fully parenthetized +ALTER TABLE a ALTER COLUMN b SET DEFAULT _ -- literals removed +ALTER TABLE _ ALTER COLUMN _ SET DEFAULT 42 -- identifiers removed + +parse +ALTER TABLE a ALTER COLUMN b SET DEFAULT NULL +---- +ALTER TABLE a ALTER COLUMN b SET DEFAULT NULL +ALTER TABLE a ALTER COLUMN b SET DEFAULT (NULL) -- fully parenthetized +ALTER TABLE a ALTER COLUMN b SET DEFAULT _ -- literals removed +ALTER TABLE _ ALTER COLUMN _ SET DEFAULT NULL -- identifiers removed + +parse +ALTER TABLE a ALTER COLUMN b DROP DEFAULT +---- +ALTER TABLE a ALTER COLUMN b DROP DEFAULT +ALTER TABLE a ALTER COLUMN b DROP DEFAULT -- fully parenthetized +ALTER TABLE a ALTER COLUMN b DROP DEFAULT -- literals removed +ALTER TABLE _ ALTER COLUMN _ DROP DEFAULT -- identifiers removed + +parse +ALTER TABLE a ALTER COLUMN b DROP NOT NULL +---- +ALTER TABLE a ALTER COLUMN b DROP NOT NULL +ALTER TABLE a ALTER COLUMN b DROP NOT NULL -- fully parenthetized +ALTER TABLE a ALTER COLUMN b DROP NOT NULL -- literals removed +ALTER TABLE _ ALTER COLUMN _ DROP NOT NULL -- identifiers removed + +parse +ALTER TABLE a ALTER b DROP NOT NULL +---- +ALTER TABLE a ALTER COLUMN b DROP NOT NULL -- normalized! +ALTER TABLE a ALTER COLUMN b DROP NOT NULL -- fully parenthetized +ALTER TABLE a ALTER COLUMN b DROP NOT NULL -- literals removed +ALTER TABLE _ ALTER COLUMN _ DROP NOT NULL -- identifiers removed + +parse +ALTER TABLE a ALTER COLUMN b DROP STORED +---- +ALTER TABLE a ALTER COLUMN b DROP STORED +ALTER TABLE a ALTER COLUMN b DROP STORED -- fully parenthetized +ALTER TABLE a ALTER COLUMN b DROP STORED -- literals removed +ALTER TABLE _ ALTER COLUMN _ DROP STORED -- identifiers removed + +parse +ALTER TABLE a ALTER b DROP STORED +---- +ALTER TABLE a ALTER COLUMN b DROP STORED -- normalized! +ALTER TABLE a ALTER COLUMN b DROP STORED -- fully parenthetized +ALTER TABLE a ALTER COLUMN b DROP STORED -- literals removed +ALTER TABLE _ ALTER COLUMN _ DROP STORED -- identifiers removed + +parse +ALTER TABLE a ALTER COLUMN b SET DATA TYPE INT8 +---- +ALTER TABLE a ALTER COLUMN b SET DATA TYPE INT8 +ALTER TABLE a ALTER COLUMN b SET DATA TYPE INT8 -- fully parenthetized +ALTER TABLE a ALTER COLUMN b SET DATA TYPE INT8 -- literals removed +ALTER TABLE _ ALTER COLUMN _ SET DATA TYPE INT8 -- identifiers removed + +parse +ALTER TABLE a ALTER b TYPE INT8 +---- +ALTER TABLE a ALTER COLUMN b SET DATA TYPE INT8 -- normalized! +ALTER TABLE a ALTER COLUMN b SET DATA TYPE INT8 -- fully parenthetized +ALTER TABLE a ALTER COLUMN b SET DATA TYPE INT8 -- literals removed +ALTER TABLE _ ALTER COLUMN _ SET DATA TYPE INT8 -- identifiers removed + +parse +ALTER TABLE a ALTER COLUMN b SET DATA TYPE STRING COLLATE en USING b::STRING +---- +ALTER TABLE a ALTER COLUMN b SET DATA TYPE STRING COLLATE en USING b::STRING +ALTER TABLE a ALTER COLUMN b SET DATA TYPE STRING COLLATE en USING ((b)::STRING) -- fully parenthetized +ALTER TABLE a ALTER COLUMN b SET DATA TYPE STRING COLLATE en USING b::STRING -- literals removed +ALTER TABLE _ ALTER COLUMN _ SET DATA TYPE STRING COLLATE en USING _::STRING -- identifiers removed + +parse +ALTER TABLE a ALTER COLUMN b SET DATA TYPE DECIMAL(10)[] +---- +ALTER TABLE a ALTER COLUMN b SET DATA TYPE DECIMAL(10)[] +ALTER TABLE a ALTER COLUMN b SET DATA TYPE DECIMAL(10)[] -- fully parenthetized +ALTER TABLE a ALTER COLUMN b SET DATA TYPE DECIMAL(10)[] -- literals removed +ALTER TABLE _ ALTER COLUMN _ SET DATA TYPE DECIMAL(10)[] -- identifiers removed + +parse +ALTER TABLE a SET SCHEMA s +---- +ALTER TABLE a SET SCHEMA s +ALTER TABLE a SET SCHEMA s -- fully parenthetized +ALTER TABLE a SET SCHEMA s -- literals removed +ALTER TABLE _ SET SCHEMA _ -- identifiers removed + +parse +ALTER TABLE IF EXISTS a SET SCHEMA s +---- +ALTER TABLE IF EXISTS a SET SCHEMA s +ALTER TABLE IF EXISTS a SET SCHEMA s -- fully parenthetized +ALTER TABLE IF EXISTS a SET SCHEMA s -- literals removed +ALTER TABLE IF EXISTS _ SET SCHEMA _ -- identifiers removed + +parse +ALTER TABLE a OWNER TO foo +---- +ALTER TABLE a OWNER TO foo +ALTER TABLE a OWNER TO foo -- fully parenthetized +ALTER TABLE a OWNER TO foo -- literals removed +ALTER TABLE _ OWNER TO _ -- identifiers removed + +parse +ALTER TABLE IF EXISTS a OWNER TO foo +---- +ALTER TABLE IF EXISTS a OWNER TO foo +ALTER TABLE IF EXISTS a OWNER TO foo -- fully parenthetized +ALTER TABLE IF EXISTS a OWNER TO foo -- literals removed +ALTER TABLE IF EXISTS _ OWNER TO _ -- identifiers removed + +parse +ALTER TABLE a SPLIT AT VALUES (1) +---- +ALTER TABLE a SPLIT AT VALUES (1) +ALTER TABLE a SPLIT AT VALUES ((1)) -- fully parenthetized +ALTER TABLE a SPLIT AT VALUES (_) -- literals removed +ALTER TABLE _ SPLIT AT VALUES (1) -- identifiers removed + +parse +EXPLAIN ALTER TABLE a SPLIT AT VALUES (1) +---- +EXPLAIN ALTER TABLE a SPLIT AT VALUES (1) +EXPLAIN ALTER TABLE a SPLIT AT VALUES ((1)) -- fully parenthetized +EXPLAIN ALTER TABLE a SPLIT AT VALUES (_) -- literals removed +EXPLAIN ALTER TABLE _ SPLIT AT VALUES (1) -- identifiers removed + +parse +ALTER TABLE a SPLIT AT SELECT * FROM t +---- +ALTER TABLE a SPLIT AT SELECT * FROM t +ALTER TABLE a SPLIT AT SELECT (*) FROM t -- fully parenthetized +ALTER TABLE a SPLIT AT SELECT * FROM t -- literals removed +ALTER TABLE _ SPLIT AT SELECT * FROM _ -- identifiers removed + +parse +ALTER TABLE d.a SPLIT AT VALUES ('b', 2) +---- +ALTER TABLE d.a SPLIT AT VALUES ('b', 2) +ALTER TABLE d.a SPLIT AT VALUES (('b'), (2)) -- fully parenthetized +ALTER TABLE d.a SPLIT AT VALUES (_, _) -- literals removed +ALTER TABLE _._ SPLIT AT VALUES ('b', 2) -- identifiers removed + +parse +ALTER TABLE a SPLIT AT VALUES (1) WITH EXPIRATION '1 day' +---- +ALTER TABLE a SPLIT AT VALUES (1) WITH EXPIRATION '1 day' +ALTER TABLE a SPLIT AT VALUES ((1)) WITH EXPIRATION ('1 day') -- fully parenthetized +ALTER TABLE a SPLIT AT VALUES (_) WITH EXPIRATION _ -- literals removed +ALTER TABLE _ SPLIT AT VALUES (1) WITH EXPIRATION '1 day' -- identifiers removed + +parse +ALTER TABLE a SPLIT AT VALUES (1) WITH EXPIRATION '1 day':::INTERVAL +---- +ALTER TABLE a SPLIT AT VALUES (1) WITH EXPIRATION '1 day':::INTERVAL +ALTER TABLE a SPLIT AT VALUES ((1)) WITH EXPIRATION (('1 day'):::INTERVAL) -- fully parenthetized +ALTER TABLE a SPLIT AT VALUES (_) WITH EXPIRATION _:::INTERVAL -- literals removed +ALTER TABLE _ SPLIT AT VALUES (1) WITH EXPIRATION '1 day':::INTERVAL -- identifiers removed + +parse +ALTER TABLE a SPLIT AT VALUES (1) WITH EXPIRATION '7258118400000000.0' +---- +ALTER TABLE a SPLIT AT VALUES (1) WITH EXPIRATION '7258118400000000.0' +ALTER TABLE a SPLIT AT VALUES ((1)) WITH EXPIRATION ('7258118400000000.0') -- fully parenthetized +ALTER TABLE a SPLIT AT VALUES (_) WITH EXPIRATION _ -- literals removed +ALTER TABLE _ SPLIT AT VALUES (1) WITH EXPIRATION '7258118400000000.0' -- identifiers removed + +parse +ALTER TABLE a SPLIT AT VALUES (1) WITH EXPIRATION '2200-01-01 00:00:00.0' +---- +ALTER TABLE a SPLIT AT VALUES (1) WITH EXPIRATION '2200-01-01 00:00:00.0' +ALTER TABLE a SPLIT AT VALUES ((1)) WITH EXPIRATION ('2200-01-01 00:00:00.0') -- fully parenthetized +ALTER TABLE a SPLIT AT VALUES (_) WITH EXPIRATION _ -- literals removed +ALTER TABLE _ SPLIT AT VALUES (1) WITH EXPIRATION '2200-01-01 00:00:00.0' -- identifiers removed + +parse +ALTER TABLE a SPLIT AT VALUES (1) WITH EXPIRATION TIMESTAMP '2200-01-01 00:00:00.0' +---- +ALTER TABLE a SPLIT AT VALUES (1) WITH EXPIRATION TIMESTAMP '2200-01-01 00:00:00.0' +ALTER TABLE a SPLIT AT VALUES ((1)) WITH EXPIRATION (TIMESTAMP ('2200-01-01 00:00:00.0')) -- fully parenthetized +ALTER TABLE a SPLIT AT VALUES (_) WITH EXPIRATION TIMESTAMP _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +ALTER TABLE _ SPLIT AT VALUES (1) WITH EXPIRATION TIMESTAMP '2200-01-01 00:00:00.0' -- identifiers removed + +parse +ALTER TABLE a SPLIT AT VALUES (1) WITH EXPIRATION '2200-01-01 00:00:00.0':::TIMESTAMP +---- +ALTER TABLE a SPLIT AT VALUES (1) WITH EXPIRATION '2200-01-01 00:00:00.0':::TIMESTAMP +ALTER TABLE a SPLIT AT VALUES ((1)) WITH EXPIRATION (('2200-01-01 00:00:00.0'):::TIMESTAMP) -- fully parenthetized +ALTER TABLE a SPLIT AT VALUES (_) WITH EXPIRATION _:::TIMESTAMP -- literals removed +ALTER TABLE _ SPLIT AT VALUES (1) WITH EXPIRATION '2200-01-01 00:00:00.0':::TIMESTAMP -- identifiers removed + +parse +ALTER TABLE a SPLIT AT VALUES (1) WITH EXPIRATION TIMESTAMPTZ '2200-01-01 00:00:00.0' +---- +ALTER TABLE a SPLIT AT VALUES (1) WITH EXPIRATION TIMESTAMPTZ '2200-01-01 00:00:00.0' +ALTER TABLE a SPLIT AT VALUES ((1)) WITH EXPIRATION (TIMESTAMPTZ ('2200-01-01 00:00:00.0')) -- fully parenthetized +ALTER TABLE a SPLIT AT VALUES (_) WITH EXPIRATION TIMESTAMPTZ _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +ALTER TABLE _ SPLIT AT VALUES (1) WITH EXPIRATION TIMESTAMPTZ '2200-01-01 00:00:00.0' -- identifiers removed + +parse +ALTER TABLE a UNSPLIT AT VALUES (1) +---- +ALTER TABLE a UNSPLIT AT VALUES (1) +ALTER TABLE a UNSPLIT AT VALUES ((1)) -- fully parenthetized +ALTER TABLE a UNSPLIT AT VALUES (_) -- literals removed +ALTER TABLE _ UNSPLIT AT VALUES (1) -- identifiers removed + +parse +EXPLAIN ALTER TABLE a UNSPLIT AT VALUES (1) +---- +EXPLAIN ALTER TABLE a UNSPLIT AT VALUES (1) +EXPLAIN ALTER TABLE a UNSPLIT AT VALUES ((1)) -- fully parenthetized +EXPLAIN ALTER TABLE a UNSPLIT AT VALUES (_) -- literals removed +EXPLAIN ALTER TABLE _ UNSPLIT AT VALUES (1) -- identifiers removed + +parse +ALTER TABLE a UNSPLIT AT SELECT * FROM t +---- +ALTER TABLE a UNSPLIT AT SELECT * FROM t +ALTER TABLE a UNSPLIT AT SELECT (*) FROM t -- fully parenthetized +ALTER TABLE a UNSPLIT AT SELECT * FROM t -- literals removed +ALTER TABLE _ UNSPLIT AT SELECT * FROM _ -- identifiers removed + +parse +ALTER TABLE d.a UNSPLIT AT VALUES ('b', 2) +---- +ALTER TABLE d.a UNSPLIT AT VALUES ('b', 2) +ALTER TABLE d.a UNSPLIT AT VALUES (('b'), (2)) -- fully parenthetized +ALTER TABLE d.a UNSPLIT AT VALUES (_, _) -- literals removed +ALTER TABLE _._ UNSPLIT AT VALUES ('b', 2) -- identifiers removed + +parse +ALTER TABLE a EXPERIMENTAL_RELOCATE VALUES (ARRAY[1], 1) +---- +ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[1], 1) -- normalized! +ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS VALUES ((ARRAY[(1)]), (1)) -- fully parenthetized +ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[_], _) -- literals removed +ALTER TABLE _ EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[1], 1) -- identifiers removed + +parse +EXPLAIN ALTER TABLE a EXPERIMENTAL_RELOCATE TABLE b +---- +EXPLAIN ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS TABLE b -- normalized! +EXPLAIN ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS TABLE b -- fully parenthetized +EXPLAIN ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS TABLE b -- literals removed +EXPLAIN ALTER TABLE _ EXPERIMENTAL_RELOCATE VOTERS TABLE _ -- identifiers removed + +parse +ALTER TABLE a EXPERIMENTAL_RELOCATE SELECT * FROM t +---- +ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS SELECT * FROM t -- normalized! +ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS SELECT (*) FROM t -- fully parenthetized +ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS SELECT * FROM t -- literals removed +ALTER TABLE _ EXPERIMENTAL_RELOCATE VOTERS SELECT * FROM _ -- identifiers removed + +parse +ALTER TABLE d.a EXPERIMENTAL_RELOCATE VALUES (ARRAY[1, 2, 3], 'b', 2) +---- +ALTER TABLE d.a EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[1, 2, 3], 'b', 2) -- normalized! +ALTER TABLE d.a EXPERIMENTAL_RELOCATE VOTERS VALUES ((ARRAY[(1), (2), (3)]), ('b'), (2)) -- fully parenthetized +ALTER TABLE d.a EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[_, _, __more1__], _, _) -- literals removed +ALTER TABLE _._ EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[1, 2, 3], 'b', 2) -- identifiers removed + +parse +ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[1], 1) +---- +ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[1], 1) +ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS VALUES ((ARRAY[(1)]), (1)) -- fully parenthetized +ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[_], _) -- literals removed +ALTER TABLE _ EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[1], 1) -- identifiers removed + +parse +EXPLAIN ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS TABLE b +---- +EXPLAIN ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS TABLE b +EXPLAIN ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS TABLE b -- fully parenthetized +EXPLAIN ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS TABLE b -- literals removed +EXPLAIN ALTER TABLE _ EXPERIMENTAL_RELOCATE VOTERS TABLE _ -- identifiers removed + +parse +ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS SELECT * FROM t +---- +ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS SELECT * FROM t +ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS SELECT (*) FROM t -- fully parenthetized +ALTER TABLE a EXPERIMENTAL_RELOCATE VOTERS SELECT * FROM t -- literals removed +ALTER TABLE _ EXPERIMENTAL_RELOCATE VOTERS SELECT * FROM _ -- identifiers removed + +parse +ALTER TABLE d.a EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[1, 2, 3], 'b', 2) +---- +ALTER TABLE d.a EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[1, 2, 3], 'b', 2) +ALTER TABLE d.a EXPERIMENTAL_RELOCATE VOTERS VALUES ((ARRAY[(1), (2), (3)]), ('b'), (2)) -- fully parenthetized +ALTER TABLE d.a EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[_, _, __more1__], _, _) -- literals removed +ALTER TABLE _._ EXPERIMENTAL_RELOCATE VOTERS VALUES (ARRAY[1, 2, 3], 'b', 2) -- identifiers removed + +parse +ALTER TABLE a EXPERIMENTAL_RELOCATE NON_VOTERS VALUES (ARRAY[1], 1) +---- +ALTER TABLE a EXPERIMENTAL_RELOCATE NON_VOTERS VALUES (ARRAY[1], 1) +ALTER TABLE a EXPERIMENTAL_RELOCATE NON_VOTERS VALUES ((ARRAY[(1)]), (1)) -- fully parenthetized +ALTER TABLE a EXPERIMENTAL_RELOCATE NON_VOTERS VALUES (ARRAY[_], _) -- literals removed +ALTER TABLE _ EXPERIMENTAL_RELOCATE NON_VOTERS VALUES (ARRAY[1], 1) -- identifiers removed + +parse +EXPLAIN ALTER TABLE a EXPERIMENTAL_RELOCATE NON_VOTERS TABLE b +---- +EXPLAIN ALTER TABLE a EXPERIMENTAL_RELOCATE NON_VOTERS TABLE b +EXPLAIN ALTER TABLE a EXPERIMENTAL_RELOCATE NON_VOTERS TABLE b -- fully parenthetized +EXPLAIN ALTER TABLE a EXPERIMENTAL_RELOCATE NON_VOTERS TABLE b -- literals removed +EXPLAIN ALTER TABLE _ EXPERIMENTAL_RELOCATE NON_VOTERS TABLE _ -- identifiers removed + +parse +ALTER TABLE a EXPERIMENTAL_RELOCATE NON_VOTERS SELECT * FROM t +---- +ALTER TABLE a EXPERIMENTAL_RELOCATE NON_VOTERS SELECT * FROM t +ALTER TABLE a EXPERIMENTAL_RELOCATE NON_VOTERS SELECT (*) FROM t -- fully parenthetized +ALTER TABLE a EXPERIMENTAL_RELOCATE NON_VOTERS SELECT * FROM t -- literals removed +ALTER TABLE _ EXPERIMENTAL_RELOCATE NON_VOTERS SELECT * FROM _ -- identifiers removed + +parse +ALTER TABLE d.a EXPERIMENTAL_RELOCATE NON_VOTERS VALUES (ARRAY[1, 2, 3], 'b', 2) +---- +ALTER TABLE d.a EXPERIMENTAL_RELOCATE NON_VOTERS VALUES (ARRAY[1, 2, 3], 'b', 2) +ALTER TABLE d.a EXPERIMENTAL_RELOCATE NON_VOTERS VALUES ((ARRAY[(1), (2), (3)]), ('b'), (2)) -- fully parenthetized +ALTER TABLE d.a EXPERIMENTAL_RELOCATE NON_VOTERS VALUES (ARRAY[_, _, __more1__], _, _) -- literals removed +ALTER TABLE _._ EXPERIMENTAL_RELOCATE NON_VOTERS VALUES (ARRAY[1, 2, 3], 'b', 2) -- identifiers removed + +parse +ALTER TABLE a EXPERIMENTAL_RELOCATE LEASE VALUES (1, 1) +---- +ALTER TABLE a EXPERIMENTAL_RELOCATE LEASE VALUES (1, 1) +ALTER TABLE a EXPERIMENTAL_RELOCATE LEASE VALUES ((1), (1)) -- fully parenthetized +ALTER TABLE a EXPERIMENTAL_RELOCATE LEASE VALUES (_, _) -- literals removed +ALTER TABLE _ EXPERIMENTAL_RELOCATE LEASE VALUES (1, 1) -- identifiers removed + +parse +ALTER TABLE a EXPERIMENTAL_RELOCATE LEASE SELECT * FROM t +---- +ALTER TABLE a EXPERIMENTAL_RELOCATE LEASE SELECT * FROM t +ALTER TABLE a EXPERIMENTAL_RELOCATE LEASE SELECT (*) FROM t -- fully parenthetized +ALTER TABLE a EXPERIMENTAL_RELOCATE LEASE SELECT * FROM t -- literals removed +ALTER TABLE _ EXPERIMENTAL_RELOCATE LEASE SELECT * FROM _ -- identifiers removed + +parse +ALTER TABLE d.a EXPERIMENTAL_RELOCATE LEASE VALUES (1, 'b', 2) +---- +ALTER TABLE d.a EXPERIMENTAL_RELOCATE LEASE VALUES (1, 'b', 2) +ALTER TABLE d.a EXPERIMENTAL_RELOCATE LEASE VALUES ((1), ('b'), (2)) -- fully parenthetized +ALTER TABLE d.a EXPERIMENTAL_RELOCATE LEASE VALUES (_, _, __more1__) -- literals removed +ALTER TABLE _._ EXPERIMENTAL_RELOCATE LEASE VALUES (1, 'b', 2) -- identifiers removed + +parse +ALTER TABLE a SCATTER +---- +ALTER TABLE a SCATTER +ALTER TABLE a SCATTER -- fully parenthetized +ALTER TABLE a SCATTER -- literals removed +ALTER TABLE _ SCATTER -- identifiers removed + +parse +EXPLAIN ALTER TABLE a SCATTER +---- +EXPLAIN ALTER TABLE a SCATTER +EXPLAIN ALTER TABLE a SCATTER -- fully parenthetized +EXPLAIN ALTER TABLE a SCATTER -- literals removed +EXPLAIN ALTER TABLE _ SCATTER -- identifiers removed + +parse +ALTER TABLE a SCATTER FROM (1, 2, 3) TO (4, 5, 6) +---- +ALTER TABLE a SCATTER FROM (1, 2, 3) TO (4, 5, 6) +ALTER TABLE a SCATTER FROM ((1), (2), (3)) TO ((4), (5), (6)) -- fully parenthetized +ALTER TABLE a SCATTER FROM (_, _, _) TO (_, _, _) -- literals removed +ALTER TABLE _ SCATTER FROM (1, 2, 3) TO (4, 5, 6) -- identifiers removed + +parse +ALTER TABLE d.a SCATTER +---- +ALTER TABLE d.a SCATTER +ALTER TABLE d.a SCATTER -- fully parenthetized +ALTER TABLE d.a SCATTER -- literals removed +ALTER TABLE _._ SCATTER -- identifiers removed + +parse +ALTER TABLE db.t CONFIGURE ZONE = 'foo' +---- +ALTER TABLE db.t CONFIGURE ZONE = 'foo' +ALTER TABLE db.t CONFIGURE ZONE = ('foo') -- fully parenthetized +ALTER TABLE db.t CONFIGURE ZONE = _ -- literals removed +ALTER TABLE _._ CONFIGURE ZONE = 'foo' -- identifiers removed + +parse +EXPLAIN ALTER TABLE db.t CONFIGURE ZONE = 'foo' +---- +EXPLAIN ALTER TABLE db.t CONFIGURE ZONE = 'foo' +EXPLAIN ALTER TABLE db.t CONFIGURE ZONE = ('foo') -- fully parenthetized +EXPLAIN ALTER TABLE db.t CONFIGURE ZONE = _ -- literals removed +EXPLAIN ALTER TABLE _._ CONFIGURE ZONE = 'foo' -- identifiers removed + +parse +ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE = 'foo' +---- +ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE = 'foo' +ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE = ('foo') -- fully parenthetized +ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE = _ -- literals removed +ALTER PARTITION _ OF TABLE _._ CONFIGURE ZONE = 'foo' -- identifiers removed + +parse +EXPLAIN ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE = 'foo' +---- +EXPLAIN ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE = 'foo' +EXPLAIN ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE = ('foo') -- fully parenthetized +EXPLAIN ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE = _ -- literals removed +EXPLAIN ALTER PARTITION _ OF TABLE _._ CONFIGURE ZONE = 'foo' -- identifiers removed + +parse +ALTER TABLE t CONFIGURE ZONE = 'foo' +---- +ALTER TABLE t CONFIGURE ZONE = 'foo' +ALTER TABLE t CONFIGURE ZONE = ('foo') -- fully parenthetized +ALTER TABLE t CONFIGURE ZONE = _ -- literals removed +ALTER TABLE _ CONFIGURE ZONE = 'foo' -- identifiers removed + +parse +ALTER PARTITION p OF TABLE t CONFIGURE ZONE = 'foo' +---- +ALTER PARTITION p OF TABLE t CONFIGURE ZONE = 'foo' +ALTER PARTITION p OF TABLE t CONFIGURE ZONE = ('foo') -- fully parenthetized +ALTER PARTITION p OF TABLE t CONFIGURE ZONE = _ -- literals removed +ALTER PARTITION _ OF TABLE _ CONFIGURE ZONE = 'foo' -- identifiers removed + +parse +ALTER TABLE t CONFIGURE ZONE = b'foo' +---- +ALTER TABLE t CONFIGURE ZONE = b'foo' +ALTER TABLE t CONFIGURE ZONE = (b'foo') -- fully parenthetized +ALTER TABLE t CONFIGURE ZONE = _ -- literals removed +ALTER TABLE _ CONFIGURE ZONE = b'foo' -- identifiers removed + +parse +ALTER TABLE t CONFIGURE ZONE = a || b +---- +ALTER TABLE t CONFIGURE ZONE = a || b +ALTER TABLE t CONFIGURE ZONE = ((a) || (b)) -- fully parenthetized +ALTER TABLE t CONFIGURE ZONE = a || b -- literals removed +ALTER TABLE _ CONFIGURE ZONE = _ || _ -- identifiers removed + +parse +ALTER TABLE db.t CONFIGURE ZONE USING foo = bar, baz = yay +---- +ALTER TABLE db.t CONFIGURE ZONE USING foo = bar, baz = yay +ALTER TABLE db.t CONFIGURE ZONE USING foo = (bar), baz = (yay) -- fully parenthetized +ALTER TABLE db.t CONFIGURE ZONE USING foo = bar, baz = yay -- literals removed +ALTER TABLE _._ CONFIGURE ZONE USING _ = _, _ = _ -- identifiers removed + +parse +ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE USING foo = bar, baz = yay +---- +ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE USING foo = bar, baz = yay +ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE USING foo = (bar), baz = (yay) -- fully parenthetized +ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE USING foo = bar, baz = yay -- literals removed +ALTER PARTITION _ OF TABLE _._ CONFIGURE ZONE USING _ = _, _ = _ -- identifiers removed + +parse +ALTER TABLE t CONFIGURE ZONE USING foo = bar, baz = yay +---- +ALTER TABLE t CONFIGURE ZONE USING foo = bar, baz = yay +ALTER TABLE t CONFIGURE ZONE USING foo = (bar), baz = (yay) -- fully parenthetized +ALTER TABLE t CONFIGURE ZONE USING foo = bar, baz = yay -- literals removed +ALTER TABLE _ CONFIGURE ZONE USING _ = _, _ = _ -- identifiers removed + +parse +ALTER TABLE db.t CONFIGURE ZONE USING foo.bar = yay +---- +ALTER TABLE db.t CONFIGURE ZONE USING "foo.bar" = yay -- normalized! +ALTER TABLE db.t CONFIGURE ZONE USING "foo.bar" = (yay) -- fully parenthetized +ALTER TABLE db.t CONFIGURE ZONE USING "foo.bar" = yay -- literals removed +ALTER TABLE _._ CONFIGURE ZONE USING _ = _ -- identifiers removed + +parse +ALTER TABLE t CONFIGURE ZONE USING foo.bar = yay +---- +ALTER TABLE t CONFIGURE ZONE USING "foo.bar" = yay -- normalized! +ALTER TABLE t CONFIGURE ZONE USING "foo.bar" = (yay) -- fully parenthetized +ALTER TABLE t CONFIGURE ZONE USING "foo.bar" = yay -- literals removed +ALTER TABLE _ CONFIGURE ZONE USING _ = _ -- identifiers removed + +parse +ALTER PARTITION p OF TABLE t CONFIGURE ZONE USING foo = bar, baz = yay +---- +ALTER PARTITION p OF TABLE t CONFIGURE ZONE USING foo = bar, baz = yay +ALTER PARTITION p OF TABLE t CONFIGURE ZONE USING foo = (bar), baz = (yay) -- fully parenthetized +ALTER PARTITION p OF TABLE t CONFIGURE ZONE USING foo = bar, baz = yay -- literals removed +ALTER PARTITION _ OF TABLE _ CONFIGURE ZONE USING _ = _, _ = _ -- identifiers removed + +parse +ALTER PARTITION p OF TABLE t CONFIGURE ZONE USING foo.bar = yay +---- +ALTER PARTITION p OF TABLE t CONFIGURE ZONE USING "foo.bar" = yay -- normalized! +ALTER PARTITION p OF TABLE t CONFIGURE ZONE USING "foo.bar" = (yay) -- fully parenthetized +ALTER PARTITION p OF TABLE t CONFIGURE ZONE USING "foo.bar" = yay -- literals removed +ALTER PARTITION _ OF TABLE _ CONFIGURE ZONE USING _ = _ -- identifiers removed + +parse +ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE USING foo.bar = yay +---- +ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE USING "foo.bar" = yay -- normalized! +ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE USING "foo.bar" = (yay) -- fully parenthetized +ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE USING "foo.bar" = yay -- literals removed +ALTER PARTITION _ OF TABLE _._ CONFIGURE ZONE USING _ = _ -- identifiers removed + +parse +ALTER TABLE db.t CONFIGURE ZONE DISCARD +---- +ALTER TABLE db.t CONFIGURE ZONE DISCARD +ALTER TABLE db.t CONFIGURE ZONE DISCARD -- fully parenthetized +ALTER TABLE db.t CONFIGURE ZONE DISCARD -- literals removed +ALTER TABLE _._ CONFIGURE ZONE DISCARD -- identifiers removed + +parse +ALTER TABLE t CONFIGURE ZONE = NULL +---- +ALTER TABLE t CONFIGURE ZONE DISCARD -- normalized! +ALTER TABLE t CONFIGURE ZONE DISCARD -- fully parenthetized +ALTER TABLE t CONFIGURE ZONE DISCARD -- literals removed +ALTER TABLE _ CONFIGURE ZONE DISCARD -- identifiers removed + +parse +ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE DISCARD +---- +ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE DISCARD +ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE DISCARD -- fully parenthetized +ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE DISCARD -- literals removed +ALTER PARTITION _ OF TABLE _._ CONFIGURE ZONE DISCARD -- identifiers removed + +parse +ALTER TABLE t CONFIGURE ZONE DISCARD +---- +ALTER TABLE t CONFIGURE ZONE DISCARD +ALTER TABLE t CONFIGURE ZONE DISCARD -- fully parenthetized +ALTER TABLE t CONFIGURE ZONE DISCARD -- literals removed +ALTER TABLE _ CONFIGURE ZONE DISCARD -- identifiers removed + +parse +ALTER PARTITION p OF TABLE t CONFIGURE ZONE DISCARD +---- +ALTER PARTITION p OF TABLE t CONFIGURE ZONE DISCARD +ALTER PARTITION p OF TABLE t CONFIGURE ZONE DISCARD -- fully parenthetized +ALTER PARTITION p OF TABLE t CONFIGURE ZONE DISCARD -- literals removed +ALTER PARTITION _ OF TABLE _ CONFIGURE ZONE DISCARD -- identifiers removed + + +parse +ALTER TABLE db.t CONFIGURE ZONE USING DEFAULT +---- +ALTER TABLE db.t CONFIGURE ZONE USING DEFAULT +ALTER TABLE db.t CONFIGURE ZONE USING DEFAULT -- fully parenthetized +ALTER TABLE db.t CONFIGURE ZONE USING DEFAULT -- literals removed +ALTER TABLE _._ CONFIGURE ZONE USING DEFAULT -- identifiers removed + +parse +ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE USING DEFAULT +---- +ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE USING DEFAULT +ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE USING DEFAULT -- fully parenthetized +ALTER PARTITION p OF TABLE db.t CONFIGURE ZONE USING DEFAULT -- literals removed +ALTER PARTITION _ OF TABLE _._ CONFIGURE ZONE USING DEFAULT -- identifiers removed + +parse +ALTER TABLE t CONFIGURE ZONE USING DEFAULT +---- +ALTER TABLE t CONFIGURE ZONE USING DEFAULT +ALTER TABLE t CONFIGURE ZONE USING DEFAULT -- fully parenthetized +ALTER TABLE t CONFIGURE ZONE USING DEFAULT -- literals removed +ALTER TABLE _ CONFIGURE ZONE USING DEFAULT -- identifiers removed + +parse +ALTER PARTITION p OF TABLE t CONFIGURE ZONE USING DEFAULT +---- +ALTER PARTITION p OF TABLE t CONFIGURE ZONE USING DEFAULT +ALTER PARTITION p OF TABLE t CONFIGURE ZONE USING DEFAULT -- fully parenthetized +ALTER PARTITION p OF TABLE t CONFIGURE ZONE USING DEFAULT -- literals removed +ALTER PARTITION _ OF TABLE _ CONFIGURE ZONE USING DEFAULT -- identifiers removed + +parse +ALTER TABLE t EXPERIMENTAL_AUDIT SET READ WRITE +---- +ALTER TABLE t EXPERIMENTAL_AUDIT SET READ WRITE +ALTER TABLE t EXPERIMENTAL_AUDIT SET READ WRITE -- fully parenthetized +ALTER TABLE t EXPERIMENTAL_AUDIT SET READ WRITE -- literals removed +ALTER TABLE _ EXPERIMENTAL_AUDIT SET READ WRITE -- identifiers removed + +parse +EXPLAIN ALTER TABLE t EXPERIMENTAL_AUDIT SET READ WRITE +---- +EXPLAIN ALTER TABLE t EXPERIMENTAL_AUDIT SET READ WRITE +EXPLAIN ALTER TABLE t EXPERIMENTAL_AUDIT SET READ WRITE -- fully parenthetized +EXPLAIN ALTER TABLE t EXPERIMENTAL_AUDIT SET READ WRITE -- literals removed +EXPLAIN ALTER TABLE _ EXPERIMENTAL_AUDIT SET READ WRITE -- identifiers removed + +parse +ALTER TABLE t EXPERIMENTAL_AUDIT SET OFF +---- +ALTER TABLE t EXPERIMENTAL_AUDIT SET OFF +ALTER TABLE t EXPERIMENTAL_AUDIT SET OFF -- fully parenthetized +ALTER TABLE t EXPERIMENTAL_AUDIT SET OFF -- literals removed +ALTER TABLE _ EXPERIMENTAL_AUDIT SET OFF -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/alter_type b/pkg/sql/parser/testdata/parse/alter_type new file mode 100644 index 000000000000..deb36cd0ac30 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/alter_type @@ -0,0 +1,87 @@ +parse +ALTER TYPE db.s.t ADD VALUE 'hi' +---- +ALTER TYPE db.s.t ADD VALUE 'hi' +ALTER TYPE db.s.t ADD VALUE 'hi' -- fully parenthetized +ALTER TYPE db.s.t ADD VALUE 'hi' -- literals removed +ALTER TYPE _._._ ADD VALUE _ -- identifiers removed + +parse +ALTER TYPE s.t ADD VALUE 'hi' BEFORE 'hello' +---- +ALTER TYPE s.t ADD VALUE 'hi' BEFORE 'hello' +ALTER TYPE s.t ADD VALUE 'hi' BEFORE 'hello' -- fully parenthetized +ALTER TYPE s.t ADD VALUE 'hi' BEFORE 'hello' -- literals removed +ALTER TYPE _._ ADD VALUE _ BEFORE _ -- identifiers removed + +parse +ALTER TYPE t ADD VALUE 'hi' AFTER 'howdy' +---- +ALTER TYPE t ADD VALUE 'hi' AFTER 'howdy' +ALTER TYPE t ADD VALUE 'hi' AFTER 'howdy' -- fully parenthetized +ALTER TYPE t ADD VALUE 'hi' AFTER 'howdy' -- literals removed +ALTER TYPE _ ADD VALUE _ AFTER _ -- identifiers removed + +parse +ALTER TYPE t DROP VALUE 'hi' +---- +ALTER TYPE t DROP VALUE 'hi' +ALTER TYPE t DROP VALUE 'hi' -- fully parenthetized +ALTER TYPE t DROP VALUE 'hi' -- literals removed +ALTER TYPE _ DROP VALUE _ -- identifiers removed + +parse +ALTER TYPE s.t ADD VALUE IF NOT EXISTS 'hi' BEFORE 'hello' +---- +ALTER TYPE s.t ADD VALUE IF NOT EXISTS 'hi' BEFORE 'hello' +ALTER TYPE s.t ADD VALUE IF NOT EXISTS 'hi' BEFORE 'hello' -- fully parenthetized +ALTER TYPE s.t ADD VALUE IF NOT EXISTS 'hi' BEFORE 'hello' -- literals removed +ALTER TYPE _._ ADD VALUE IF NOT EXISTS _ BEFORE _ -- identifiers removed + +parse +ALTER TYPE t RENAME VALUE 'value1' TO 'value2' +---- +ALTER TYPE t RENAME VALUE 'value1' TO 'value2' +ALTER TYPE t RENAME VALUE 'value1' TO 'value2' -- fully parenthetized +ALTER TYPE t RENAME VALUE 'value1' TO 'value2' -- literals removed +ALTER TYPE _ RENAME VALUE _ TO _ -- identifiers removed + +parse +ALTER TYPE t RENAME TO t2 +---- +ALTER TYPE t RENAME TO t2 +ALTER TYPE t RENAME TO t2 -- fully parenthetized +ALTER TYPE t RENAME TO t2 -- literals removed +ALTER TYPE _ RENAME TO _ -- identifiers removed + +parse +ALTER TYPE t SET SCHEMA newschema +---- +ALTER TYPE t SET SCHEMA newschema +ALTER TYPE t SET SCHEMA newschema -- fully parenthetized +ALTER TYPE t SET SCHEMA newschema -- literals removed +ALTER TYPE _ SET SCHEMA _ -- identifiers removed + +parse +ALTER TYPE t OWNER TO foo +---- +ALTER TYPE t OWNER TO foo +ALTER TYPE t OWNER TO foo -- fully parenthetized +ALTER TYPE t OWNER TO foo -- literals removed +ALTER TYPE _ OWNER TO _ -- identifiers removed + +parse +ALTER TYPE t OWNER TO CURRENT_USER +---- +ALTER TYPE t OWNER TO "current_user" -- normalized! +ALTER TYPE t OWNER TO "current_user" -- fully parenthetized +ALTER TYPE t OWNER TO "current_user" -- literals removed +ALTER TYPE _ OWNER TO _ -- identifiers removed + +parse +ALTER TYPE t OWNER TO SESSION_USER +---- +ALTER TYPE t OWNER TO "session_user" -- normalized! +ALTER TYPE t OWNER TO "session_user" -- fully parenthetized +ALTER TYPE t OWNER TO "session_user" -- literals removed +ALTER TYPE _ OWNER TO _ -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/alter_user b/pkg/sql/parser/testdata/parse/alter_user new file mode 100644 index 000000000000..64ed095ea0cd --- /dev/null +++ b/pkg/sql/parser/testdata/parse/alter_user @@ -0,0 +1,82 @@ +parse +ALTER USER foo PASSWORD bar +---- +ALTER USER 'foo' WITH PASSWORD '*****' -- normalized! +ALTER USER ('foo') WITH PASSWORD '*****' -- fully parenthetized +ALTER USER _ WITH PASSWORD '*****' -- literals removed +ALTER USER '_' WITH PASSWORD '*****' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +ALTER USER 'foo' WITH PASSWORD '*****' -- identifiers removed +ALTER USER 'foo' WITH PASSWORD 'bar' -- passwords exposed + +parse +ALTER USER foo WITH PASSWORD bar +---- +ALTER USER 'foo' WITH PASSWORD '*****' -- normalized! +ALTER USER ('foo') WITH PASSWORD '*****' -- fully parenthetized +ALTER USER _ WITH PASSWORD '*****' -- literals removed +ALTER USER '_' WITH PASSWORD '*****' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +ALTER USER 'foo' WITH PASSWORD '*****' -- identifiers removed +ALTER USER 'foo' WITH PASSWORD 'bar' -- passwords exposed + +parse +ALTER USER foo WITH PASSWORD NULL +---- +ALTER USER 'foo' WITH PASSWORD NULL -- normalized! +ALTER USER ('foo') WITH PASSWORD (NULL) -- fully parenthetized +ALTER USER _ WITH PASSWORD _ -- literals removed +ALTER USER '_' WITH PASSWORD '*****' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +ALTER USER 'foo' WITH PASSWORD NULL -- identifiers removed + +parse +ALTER ROLE foo WITH CREATEDB +---- +ALTER ROLE 'foo' WITH CREATEDB -- normalized! +ALTER ROLE ('foo') WITH CREATEDB -- fully parenthetized +ALTER ROLE _ WITH CREATEDB -- literals removed +ALTER ROLE '_' WITH CREATEDB -- UNEXPECTED REPARSED AST WITHOUT LITERALS +ALTER ROLE 'foo' WITH CREATEDB -- identifiers removed + +parse +ALTER ROLE foo CREATEDB +---- +ALTER ROLE 'foo' WITH CREATEDB -- normalized! +ALTER ROLE ('foo') WITH CREATEDB -- fully parenthetized +ALTER ROLE _ WITH CREATEDB -- literals removed +ALTER ROLE '_' WITH CREATEDB -- UNEXPECTED REPARSED AST WITHOUT LITERALS +ALTER ROLE 'foo' WITH CREATEDB -- identifiers removed + +parse +ALTER ROLE foo WITH CREATEROLE +---- +ALTER ROLE 'foo' WITH CREATEROLE -- normalized! +ALTER ROLE ('foo') WITH CREATEROLE -- fully parenthetized +ALTER ROLE _ WITH CREATEROLE -- literals removed +ALTER ROLE '_' WITH CREATEROLE -- UNEXPECTED REPARSED AST WITHOUT LITERALS +ALTER ROLE 'foo' WITH CREATEROLE -- identifiers removed + +parse +ALTER ROLE foo CREATEROLE +---- +ALTER ROLE 'foo' WITH CREATEROLE -- normalized! +ALTER ROLE ('foo') WITH CREATEROLE -- fully parenthetized +ALTER ROLE _ WITH CREATEROLE -- literals removed +ALTER ROLE '_' WITH CREATEROLE -- UNEXPECTED REPARSED AST WITHOUT LITERALS +ALTER ROLE 'foo' WITH CREATEROLE -- identifiers removed + +parse +ALTER ROLE foo CREATELOGIN +---- +ALTER ROLE 'foo' WITH CREATELOGIN -- normalized! +ALTER ROLE ('foo') WITH CREATELOGIN -- fully parenthetized +ALTER ROLE _ WITH CREATELOGIN -- literals removed +ALTER ROLE '_' WITH CREATELOGIN -- UNEXPECTED REPARSED AST WITHOUT LITERALS +ALTER ROLE 'foo' WITH CREATELOGIN -- identifiers removed + +parse +ALTER ROLE foo NOCREATELOGIN +---- +ALTER ROLE 'foo' WITH NOCREATELOGIN -- normalized! +ALTER ROLE ('foo') WITH NOCREATELOGIN -- fully parenthetized +ALTER ROLE _ WITH NOCREATELOGIN -- literals removed +ALTER ROLE '_' WITH NOCREATELOGIN -- UNEXPECTED REPARSED AST WITHOUT LITERALS +ALTER ROLE 'foo' WITH NOCREATELOGIN -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/alter_view b/pkg/sql/parser/testdata/parse/alter_view new file mode 100644 index 000000000000..c0802148ce96 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/alter_view @@ -0,0 +1,63 @@ +parse +ALTER VIEW v SET SCHEMA s +---- +ALTER VIEW v SET SCHEMA s +ALTER VIEW v SET SCHEMA s -- fully parenthetized +ALTER VIEW v SET SCHEMA s -- literals removed +ALTER VIEW _ SET SCHEMA _ -- identifiers removed + +parse +ALTER VIEW IF EXISTS a SET SCHEMA s +---- +ALTER VIEW IF EXISTS a SET SCHEMA s +ALTER VIEW IF EXISTS a SET SCHEMA s -- fully parenthetized +ALTER VIEW IF EXISTS a SET SCHEMA s -- literals removed +ALTER VIEW IF EXISTS _ SET SCHEMA _ -- identifiers removed + +parse +ALTER MATERIALIZED VIEW v SET SCHEMA s +---- +ALTER MATERIALIZED VIEW v SET SCHEMA s +ALTER MATERIALIZED VIEW v SET SCHEMA s -- fully parenthetized +ALTER MATERIALIZED VIEW v SET SCHEMA s -- literals removed +ALTER MATERIALIZED VIEW _ SET SCHEMA _ -- identifiers removed + +parse +ALTER MATERIALIZED VIEW IF EXISTS a SET SCHEMA s +---- +ALTER MATERIALIZED VIEW IF EXISTS a SET SCHEMA s +ALTER MATERIALIZED VIEW IF EXISTS a SET SCHEMA s -- fully parenthetized +ALTER MATERIALIZED VIEW IF EXISTS a SET SCHEMA s -- literals removed +ALTER MATERIALIZED VIEW IF EXISTS _ SET SCHEMA _ -- identifiers removed + +parse +ALTER VIEW v RENAME TO v +---- +ALTER VIEW v RENAME TO v +ALTER VIEW v RENAME TO v -- fully parenthetized +ALTER VIEW v RENAME TO v -- literals removed +ALTER VIEW _ RENAME TO _ -- identifiers removed + +parse +ALTER VIEW IF EXISTS v RENAME TO v +---- +ALTER VIEW IF EXISTS v RENAME TO v +ALTER VIEW IF EXISTS v RENAME TO v -- fully parenthetized +ALTER VIEW IF EXISTS v RENAME TO v -- literals removed +ALTER VIEW IF EXISTS _ RENAME TO _ -- identifiers removed + +parse +ALTER MATERIALIZED VIEW v RENAME TO v +---- +ALTER MATERIALIZED VIEW v RENAME TO v +ALTER MATERIALIZED VIEW v RENAME TO v -- fully parenthetized +ALTER MATERIALIZED VIEW v RENAME TO v -- literals removed +ALTER MATERIALIZED VIEW _ RENAME TO _ -- identifiers removed + +parse +ALTER MATERIALIZED VIEW IF EXISTS v RENAME TO v +---- +ALTER MATERIALIZED VIEW IF EXISTS v RENAME TO v +ALTER MATERIALIZED VIEW IF EXISTS v RENAME TO v -- fully parenthetized +ALTER MATERIALIZED VIEW IF EXISTS v RENAME TO v -- literals removed +ALTER MATERIALIZED VIEW IF EXISTS _ RENAME TO _ -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/analyze b/pkg/sql/parser/testdata/parse/analyze new file mode 100644 index 000000000000..f36b8ee6a50e --- /dev/null +++ b/pkg/sql/parser/testdata/parse/analyze @@ -0,0 +1,15 @@ +parse +ANALYZE t +---- +ANALYZE t +ANALYZE t -- fully parenthetized +ANALYZE t -- literals removed +ANALYZE _ -- identifiers removed + +parse +ANALYZE db.sc.t +---- +ANALYZE db.sc.t +ANALYZE db.sc.t -- fully parenthetized +ANALYZE db.sc.t -- literals removed +ANALYZE _._._ -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/backup_restore b/pkg/sql/parser/testdata/parse/backup_restore new file mode 100644 index 000000000000..ee3d5e4393b2 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/backup_restore @@ -0,0 +1,761 @@ +parse +BACKUP TABLE foo TO 'bar' +---- +BACKUP TABLE foo TO 'bar' +BACKUP TABLE (foo) TO ('bar') -- fully parenthetized +BACKUP TABLE foo TO _ -- literals removed +BACKUP TABLE foo TO '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP TABLE _ TO 'bar' -- identifiers removed + +parse +BACKUP foo TO 'bar' +---- +BACKUP TABLE foo TO 'bar' -- normalized! +BACKUP TABLE (foo) TO ('bar') -- fully parenthetized +BACKUP TABLE foo TO _ -- literals removed +BACKUP TABLE foo TO '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP TABLE _ TO 'bar' -- identifiers removed + +parse +BACKUP TO 'bar' +---- +BACKUP TO 'bar' +BACKUP TO ('bar') -- fully parenthetized +BACKUP TO _ -- literals removed +BACKUP TO '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP TO 'bar' -- identifiers removed + +parse +BACKUP role TO 'bar' +---- +BACKUP TABLE role TO 'bar' -- normalized! +BACKUP TABLE (role) TO ('bar') -- fully parenthetized +BACKUP TABLE role TO _ -- literals removed +BACKUP TABLE role TO '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP TABLE _ TO 'bar' -- identifiers removed + +parse +BACKUP TABLE foo INTO 'bar' +---- +BACKUP TABLE foo INTO 'bar' +BACKUP TABLE (foo) INTO ('bar') -- fully parenthetized +BACKUP TABLE foo INTO _ -- literals removed +BACKUP TABLE foo INTO '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP TABLE _ INTO 'bar' -- identifiers removed + +parse +BACKUP TABLE foo INTO LATEST IN 'bar' +---- +BACKUP TABLE foo INTO LATEST IN 'bar' +BACKUP TABLE (foo) INTO LATEST IN ('bar') -- fully parenthetized +BACKUP TABLE foo INTO LATEST IN _ -- literals removed +BACKUP TABLE foo INTO LATEST IN '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP TABLE _ INTO LATEST IN 'bar' -- identifiers removed + +parse +BACKUP TABLE foo INTO 'subdir' IN 'bar' +---- +BACKUP TABLE foo INTO 'subdir' IN 'bar' +BACKUP TABLE (foo) INTO ('subdir') IN ('bar') -- fully parenthetized +BACKUP TABLE foo INTO _ IN _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "in": syntax error +BACKUP TABLE _ INTO 'subdir' IN 'bar' -- identifiers removed + +parse +BACKUP TABLE foo INTO $1 IN $2 +---- +BACKUP TABLE foo INTO $1 IN $2 +BACKUP TABLE (foo) INTO ($1) IN ($2) -- fully parenthetized +BACKUP TABLE foo INTO $1 IN $2 -- literals removed +BACKUP TABLE _ INTO $1 IN $2 -- identifiers removed + +parse +EXPLAIN BACKUP TABLE foo TO 'bar' +---- +EXPLAIN BACKUP TABLE foo TO 'bar' +EXPLAIN BACKUP TABLE (foo) TO ('bar') -- fully parenthetized +EXPLAIN BACKUP TABLE foo TO _ -- literals removed +EXPLAIN BACKUP TABLE foo TO '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +EXPLAIN BACKUP TABLE _ TO 'bar' -- identifiers removed + +parse +BACKUP TABLE foo.foo, baz.baz TO 'bar' +---- +BACKUP TABLE foo.foo, baz.baz TO 'bar' +BACKUP TABLE (foo.foo), (baz.baz) TO ('bar') -- fully parenthetized +BACKUP TABLE foo.foo, baz.baz TO _ -- literals removed +BACKUP TABLE foo.foo, baz.baz TO '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP TABLE _._, _._ TO 'bar' -- identifiers removed + +parse +BACKUP foo.foo, baz.baz TO 'bar' +---- +BACKUP TABLE foo.foo, baz.baz TO 'bar' -- normalized! +BACKUP TABLE (foo.foo), (baz.baz) TO ('bar') -- fully parenthetized +BACKUP TABLE foo.foo, baz.baz TO _ -- literals removed +BACKUP TABLE foo.foo, baz.baz TO '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP TABLE _._, _._ TO 'bar' -- identifiers removed + +parse +SHOW BACKUP 'bar' +---- +SHOW BACKUP 'bar' +SHOW BACKUP ('bar') -- fully parenthetized +SHOW BACKUP _ -- literals removed +SHOW BACKUP '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SHOW BACKUP 'bar' -- identifiers removed + +parse +SHOW BACKUP 'bar' WITH foo = 'bar' +---- +SHOW BACKUP 'bar' WITH foo = 'bar' +SHOW BACKUP ('bar') WITH foo = ('bar') -- fully parenthetized +SHOW BACKUP _ WITH foo = _ -- literals removed +SHOW BACKUP '_' WITH foo = '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SHOW BACKUP 'bar' WITH _ = 'bar' -- identifiers removed + +parse +EXPLAIN SHOW BACKUP 'bar' +---- +EXPLAIN SHOW BACKUP 'bar' +EXPLAIN SHOW BACKUP ('bar') -- fully parenthetized +EXPLAIN SHOW BACKUP _ -- literals removed +EXPLAIN SHOW BACKUP '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +EXPLAIN SHOW BACKUP 'bar' -- identifiers removed + +parse +SHOW BACKUP RANGES 'bar' +---- +SHOW BACKUP RANGES 'bar' +SHOW BACKUP RANGES ('bar') -- fully parenthetized +SHOW BACKUP RANGES _ -- literals removed +SHOW BACKUP RANGES '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SHOW BACKUP RANGES 'bar' -- identifiers removed + +parse +SHOW BACKUP FILES 'bar' +---- +SHOW BACKUP FILES 'bar' +SHOW BACKUP FILES ('bar') -- fully parenthetized +SHOW BACKUP FILES _ -- literals removed +SHOW BACKUP FILES '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SHOW BACKUP FILES 'bar' -- identifiers removed + +parse +SHOW BACKUP FILES 'bar' WITH foo = 'bar' +---- +SHOW BACKUP FILES 'bar' WITH foo = 'bar' +SHOW BACKUP FILES ('bar') WITH foo = ('bar') -- fully parenthetized +SHOW BACKUP FILES _ WITH foo = _ -- literals removed +SHOW BACKUP FILES '_' WITH foo = '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SHOW BACKUP FILES 'bar' WITH _ = 'bar' -- identifiers removed + +parse +SHOW BACKUPS IN 'bar' +---- +SHOW BACKUPS IN 'bar' +SHOW BACKUPS IN ('bar') -- fully parenthetized +SHOW BACKUPS IN _ -- literals removed +SHOW BACKUPS IN '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SHOW BACKUPS IN 'bar' -- identifiers removed + +parse +SHOW BACKUPS IN $1 +---- +SHOW BACKUPS IN $1 +SHOW BACKUPS IN ($1) -- fully parenthetized +SHOW BACKUPS IN $1 -- literals removed +SHOW BACKUPS IN $1 -- identifiers removed + +parse +SHOW BACKUP 'foo' IN 'bar' +---- +SHOW BACKUP 'foo' IN 'bar' +SHOW BACKUP ('foo') IN ('bar') -- fully parenthetized +SHOW BACKUP _ IN _ -- literals removed +SHOW BACKUP '_' IN '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SHOW BACKUP 'foo' IN 'bar' -- identifiers removed + +parse +SHOW BACKUP $1 IN $2 WITH foo = 'bar' +---- +SHOW BACKUP $1 IN $2 WITH foo = 'bar' +SHOW BACKUP ($1) IN ($2) WITH foo = ('bar') -- fully parenthetized +SHOW BACKUP $1 IN $2 WITH foo = _ -- literals removed +SHOW BACKUP $1 IN $2 WITH foo = '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SHOW BACKUP $1 IN $2 WITH _ = 'bar' -- identifiers removed + +parse +BACKUP TABLE foo TO 'bar' AS OF SYSTEM TIME '1' INCREMENTAL FROM 'baz' +---- +BACKUP TABLE foo TO 'bar' AS OF SYSTEM TIME '1' INCREMENTAL FROM 'baz' +BACKUP TABLE (foo) TO ('bar') AS OF SYSTEM TIME ('1') INCREMENTAL FROM ('baz') -- fully parenthetized +BACKUP TABLE foo TO _ AS OF SYSTEM TIME _ INCREMENTAL FROM _ -- literals removed +BACKUP TABLE foo TO '_' AS OF SYSTEM TIME _ INCREMENTAL FROM '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP TABLE _ TO 'bar' AS OF SYSTEM TIME '1' INCREMENTAL FROM 'baz' -- identifiers removed + +parse +BACKUP foo TO 'bar' AS OF SYSTEM TIME '1' INCREMENTAL FROM 'baz' +---- +BACKUP TABLE foo TO 'bar' AS OF SYSTEM TIME '1' INCREMENTAL FROM 'baz' -- normalized! +BACKUP TABLE (foo) TO ('bar') AS OF SYSTEM TIME ('1') INCREMENTAL FROM ('baz') -- fully parenthetized +BACKUP TABLE foo TO _ AS OF SYSTEM TIME _ INCREMENTAL FROM _ -- literals removed +BACKUP TABLE foo TO '_' AS OF SYSTEM TIME _ INCREMENTAL FROM '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP TABLE _ TO 'bar' AS OF SYSTEM TIME '1' INCREMENTAL FROM 'baz' -- identifiers removed + +parse +BACKUP TABLE foo TO $1 INCREMENTAL FROM 'bar', $2, 'baz' +---- +BACKUP TABLE foo TO $1 INCREMENTAL FROM 'bar', $2, 'baz' +BACKUP TABLE (foo) TO ($1) INCREMENTAL FROM ('bar'), ($2), ('baz') -- fully parenthetized +BACKUP TABLE foo TO $1 INCREMENTAL FROM _, $2, _ -- literals removed +BACKUP TABLE foo TO $1 INCREMENTAL FROM '_', $2, '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP TABLE _ TO $1 INCREMENTAL FROM 'bar', $2, 'baz' -- identifiers removed + +parse +BACKUP foo TO $1 INCREMENTAL FROM 'bar', $2, 'baz' +---- +BACKUP TABLE foo TO $1 INCREMENTAL FROM 'bar', $2, 'baz' -- normalized! +BACKUP TABLE (foo) TO ($1) INCREMENTAL FROM ('bar'), ($2), ('baz') -- fully parenthetized +BACKUP TABLE foo TO $1 INCREMENTAL FROM _, $2, _ -- literals removed +BACKUP TABLE foo TO $1 INCREMENTAL FROM '_', $2, '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP TABLE _ TO $1 INCREMENTAL FROM 'bar', $2, 'baz' -- identifiers removed + +parse +BACKUP DATABASE foo TO 'bar' +---- +BACKUP DATABASE foo TO 'bar' +BACKUP DATABASE foo TO ('bar') -- fully parenthetized +BACKUP DATABASE foo TO _ -- literals removed +BACKUP DATABASE foo TO '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP DATABASE _ TO 'bar' -- identifiers removed + +parse +BACKUP DATABASE foo TO ($1) +---- +BACKUP DATABASE foo TO $1 -- normalized! +BACKUP DATABASE foo TO ($1) -- fully parenthetized +BACKUP DATABASE foo TO $1 -- literals removed +BACKUP DATABASE _ TO $1 -- identifiers removed + +parse +EXPLAIN BACKUP DATABASE foo TO 'bar' +---- +EXPLAIN BACKUP DATABASE foo TO 'bar' +EXPLAIN BACKUP DATABASE foo TO ('bar') -- fully parenthetized +EXPLAIN BACKUP DATABASE foo TO _ -- literals removed +EXPLAIN BACKUP DATABASE foo TO '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +EXPLAIN BACKUP DATABASE _ TO 'bar' -- identifiers removed + +parse +BACKUP DATABASE foo TO bar +---- +BACKUP DATABASE foo TO 'bar' -- normalized! +BACKUP DATABASE foo TO ('bar') -- fully parenthetized +BACKUP DATABASE foo TO _ -- literals removed +BACKUP DATABASE foo TO '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP DATABASE _ TO 'bar' -- identifiers removed + + +parse +BACKUP DATABASE foo, baz TO 'bar' +---- +BACKUP DATABASE foo, baz TO 'bar' +BACKUP DATABASE foo, baz TO ('bar') -- fully parenthetized +BACKUP DATABASE foo, baz TO _ -- literals removed +BACKUP DATABASE foo, baz TO '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP DATABASE _, _ TO 'bar' -- identifiers removed + +parse +BACKUP DATABASE foo TO "bar.12" INCREMENTAL FROM "baz.34" +---- +BACKUP DATABASE foo TO 'bar.12' INCREMENTAL FROM 'baz.34' -- normalized! +BACKUP DATABASE foo TO ('bar.12') INCREMENTAL FROM ('baz.34') -- fully parenthetized +BACKUP DATABASE foo TO _ INCREMENTAL FROM _ -- literals removed +BACKUP DATABASE foo TO '_' INCREMENTAL FROM '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP DATABASE _ TO 'bar.12' INCREMENTAL FROM 'baz.34' -- identifiers removed + + +parse +BACKUP DATABASE foo TO 'bar' AS OF SYSTEM TIME '1' INCREMENTAL FROM 'baz' +---- +BACKUP DATABASE foo TO 'bar' AS OF SYSTEM TIME '1' INCREMENTAL FROM 'baz' +BACKUP DATABASE foo TO ('bar') AS OF SYSTEM TIME ('1') INCREMENTAL FROM ('baz') -- fully parenthetized +BACKUP DATABASE foo TO _ AS OF SYSTEM TIME _ INCREMENTAL FROM _ -- literals removed +BACKUP DATABASE foo TO '_' AS OF SYSTEM TIME _ INCREMENTAL FROM '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP DATABASE _ TO 'bar' AS OF SYSTEM TIME '1' INCREMENTAL FROM 'baz' -- identifiers removed + +parse +BACKUP DATABASE foo TO ($1, $2) +---- +BACKUP DATABASE foo TO ($1, $2) +BACKUP DATABASE foo TO (($1), ($2)) -- fully parenthetized +BACKUP DATABASE foo TO ($1, $2) -- literals removed +BACKUP DATABASE _ TO ($1, $2) -- identifiers removed + +parse +BACKUP DATABASE foo TO ($1, $2) INCREMENTAL FROM 'baz' +---- +BACKUP DATABASE foo TO ($1, $2) INCREMENTAL FROM 'baz' +BACKUP DATABASE foo TO (($1), ($2)) INCREMENTAL FROM ('baz') -- fully parenthetized +BACKUP DATABASE foo TO ($1, $2) INCREMENTAL FROM _ -- literals removed +BACKUP DATABASE foo TO ($1, $2) INCREMENTAL FROM '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP DATABASE _ TO ($1, $2) INCREMENTAL FROM 'baz' -- identifiers removed + +parse +BACKUP foo TO 'bar' WITH ENCRYPTION_PASSPHRASE = 'secret', revision_history +---- +BACKUP TABLE foo TO 'bar' WITH revision_history, encryption_passphrase = '*****' -- normalized! +BACKUP TABLE (foo) TO ('bar') WITH revision_history, encryption_passphrase = '*****' -- fully parenthetized +BACKUP TABLE foo TO _ WITH revision_history, encryption_passphrase = '*****' -- literals removed +BACKUP TABLE foo TO '_' WITH revision_history, encryption_passphrase = '*****' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP TABLE _ TO 'bar' WITH revision_history, encryption_passphrase = '*****' -- identifiers removed +BACKUP TABLE foo TO 'bar' WITH revision_history, encryption_passphrase = 'secret' -- passwords exposed + +parse +BACKUP foo TO 'bar' WITH KMS = 'foo', revision_history +---- +BACKUP TABLE foo TO 'bar' WITH revision_history, kms = 'foo' -- normalized! +BACKUP TABLE (foo) TO ('bar') WITH revision_history, kms = ('foo') -- fully parenthetized +BACKUP TABLE foo TO _ WITH revision_history, kms = _ -- literals removed +BACKUP TABLE foo TO '_' WITH revision_history, kms = '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP TABLE _ TO 'bar' WITH revision_history, kms = 'foo' -- identifiers removed + +parse +BACKUP foo TO 'bar' WITH KMS = ('foo', 'bar'), revision_history +---- +BACKUP TABLE foo TO 'bar' WITH revision_history, kms = ('foo', 'bar') -- normalized! +BACKUP TABLE (foo) TO ('bar') WITH revision_history, kms = (('foo'), ('bar')) -- fully parenthetized +BACKUP TABLE foo TO _ WITH revision_history, kms = (_, _) -- literals removed +BACKUP TABLE foo TO '_' WITH revision_history, kms = ('_', '_') -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP TABLE _ TO 'bar' WITH revision_history, kms = ('foo', 'bar') -- identifiers removed + +parse +BACKUP foo TO 'bar' WITH OPTIONS (detached, ENCRYPTION_PASSPHRASE = 'secret', revision_history) +---- +BACKUP TABLE foo TO 'bar' WITH revision_history, encryption_passphrase = '*****', detached -- normalized! +BACKUP TABLE (foo) TO ('bar') WITH revision_history, encryption_passphrase = '*****', detached -- fully parenthetized +BACKUP TABLE foo TO _ WITH revision_history, encryption_passphrase = '*****', detached -- literals removed +BACKUP TABLE foo TO '_' WITH revision_history, encryption_passphrase = '*****', detached -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP TABLE _ TO 'bar' WITH revision_history, encryption_passphrase = '*****', detached -- identifiers removed +BACKUP TABLE foo TO 'bar' WITH revision_history, encryption_passphrase = 'secret', detached -- passwords exposed + +parse +BACKUP foo TO 'bar' WITH OPTIONS (detached, KMS = ('foo', 'bar'), revision_history) +---- +BACKUP TABLE foo TO 'bar' WITH revision_history, detached, kms = ('foo', 'bar') -- normalized! +BACKUP TABLE (foo) TO ('bar') WITH revision_history, detached, kms = (('foo'), ('bar')) -- fully parenthetized +BACKUP TABLE foo TO _ WITH revision_history, detached, kms = (_, _) -- literals removed +BACKUP TABLE foo TO '_' WITH revision_history, detached, kms = ('_', '_') -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP TABLE _ TO 'bar' WITH revision_history, detached, kms = ('foo', 'bar') -- identifiers removed + +parse +BACKUP TENANT 36 TO 'bar' +---- +BACKUP TENANT 36 TO 'bar' +BACKUP TENANT 36 TO ('bar') -- fully parenthetized +BACKUP TENANT 36 TO _ -- literals removed +BACKUP TENANT 36 TO '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP TENANT 36 TO 'bar' -- identifiers removed + +parse +RESTORE TABLE foo FROM 'bar' +---- +RESTORE TABLE foo FROM 'bar' +RESTORE TABLE (foo) FROM ('bar') -- fully parenthetized +RESTORE TABLE foo FROM _ -- literals removed +RESTORE TABLE foo FROM '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE TABLE _ FROM 'bar' -- identifiers removed + +parse +EXPLAIN RESTORE TABLE foo FROM 'bar' +---- +EXPLAIN RESTORE TABLE foo FROM 'bar' +EXPLAIN RESTORE TABLE (foo) FROM ('bar') -- fully parenthetized +EXPLAIN RESTORE TABLE foo FROM _ -- literals removed +EXPLAIN RESTORE TABLE foo FROM '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +EXPLAIN RESTORE TABLE _ FROM 'bar' -- identifiers removed + +parse +RESTORE foo FROM 'bar' +---- +RESTORE TABLE foo FROM 'bar' -- normalized! +RESTORE TABLE (foo) FROM ('bar') -- fully parenthetized +RESTORE TABLE foo FROM _ -- literals removed +RESTORE TABLE foo FROM '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE TABLE _ FROM 'bar' -- identifiers removed + +parse +RESTORE TABLE foo FROM $1 +---- +RESTORE TABLE foo FROM $1 +RESTORE TABLE (foo) FROM ($1) -- fully parenthetized +RESTORE TABLE foo FROM $1 -- literals removed +RESTORE TABLE _ FROM $1 -- identifiers removed + + +parse +RESTORE foo FROM $1 +---- +RESTORE TABLE foo FROM $1 -- normalized! +RESTORE TABLE (foo) FROM ($1) -- fully parenthetized +RESTORE TABLE foo FROM $1 -- literals removed +RESTORE TABLE _ FROM $1 -- identifiers removed + +parse +RESTORE TABLE foo FROM $2 IN $1 +---- +RESTORE TABLE foo FROM $2 IN $1 +RESTORE TABLE (foo) FROM ($2) IN ($1) -- fully parenthetized +RESTORE TABLE foo FROM $2 IN $1 -- literals removed +RESTORE TABLE _ FROM $2 IN $1 -- identifiers removed + +parse +RESTORE TABLE foo FROM $1, $2, 'bar' +---- +RESTORE TABLE foo FROM $1, $2, 'bar' +RESTORE TABLE (foo) FROM ($1), ($2), ('bar') -- fully parenthetized +RESTORE TABLE foo FROM $1, $2, _ -- literals removed +RESTORE TABLE foo FROM $1, $2, '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE TABLE _ FROM $1, $2, 'bar' -- identifiers removed + +parse +RESTORE foo FROM $1, $2, 'bar' +---- +RESTORE TABLE foo FROM $1, $2, 'bar' -- normalized! +RESTORE TABLE (foo) FROM ($1), ($2), ('bar') -- fully parenthetized +RESTORE TABLE foo FROM $1, $2, _ -- literals removed +RESTORE TABLE foo FROM $1, $2, '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE TABLE _ FROM $1, $2, 'bar' -- identifiers removed + +parse +RESTORE TABLE foo FROM 'abc' IN $1, $2, 'bar' +---- +RESTORE TABLE foo FROM 'abc' IN $1, $2, 'bar' +RESTORE TABLE (foo) FROM ('abc') IN ($1), ($2), ('bar') -- fully parenthetized +RESTORE TABLE foo FROM _ IN $1, $2, _ -- literals removed +RESTORE TABLE foo FROM '_' IN $1, $2, '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE TABLE _ FROM 'abc' IN $1, $2, 'bar' -- identifiers removed + +parse +RESTORE TABLE foo FROM $4 IN $1, $2, 'bar' +---- +RESTORE TABLE foo FROM $4 IN $1, $2, 'bar' +RESTORE TABLE (foo) FROM ($4) IN ($1), ($2), ('bar') -- fully parenthetized +RESTORE TABLE foo FROM $4 IN $1, $2, _ -- literals removed +RESTORE TABLE foo FROM $4 IN $1, $2, '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE TABLE _ FROM $4 IN $1, $2, 'bar' -- identifiers removed + +parse +RESTORE TABLE foo, baz FROM 'bar' +---- +RESTORE TABLE foo, baz FROM 'bar' +RESTORE TABLE (foo), (baz) FROM ('bar') -- fully parenthetized +RESTORE TABLE foo, baz FROM _ -- literals removed +RESTORE TABLE foo, baz FROM '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE TABLE _, _ FROM 'bar' -- identifiers removed + + +parse +RESTORE foo, baz FROM 'bar' +---- +RESTORE TABLE foo, baz FROM 'bar' -- normalized! +RESTORE TABLE (foo), (baz) FROM ('bar') -- fully parenthetized +RESTORE TABLE foo, baz FROM _ -- literals removed +RESTORE TABLE foo, baz FROM '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE TABLE _, _ FROM 'bar' -- identifiers removed + +parse +RESTORE TABLE foo, baz FROM 'bar' AS OF SYSTEM TIME '1' +---- +RESTORE TABLE foo, baz FROM 'bar' AS OF SYSTEM TIME '1' +RESTORE TABLE (foo), (baz) FROM ('bar') AS OF SYSTEM TIME ('1') -- fully parenthetized +RESTORE TABLE foo, baz FROM _ AS OF SYSTEM TIME _ -- literals removed +RESTORE TABLE foo, baz FROM '_' AS OF SYSTEM TIME _ -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE TABLE _, _ FROM 'bar' AS OF SYSTEM TIME '1' -- identifiers removed + + +parse +RESTORE foo, baz FROM 'bar' AS OF SYSTEM TIME '1' +---- +RESTORE TABLE foo, baz FROM 'bar' AS OF SYSTEM TIME '1' -- normalized! +RESTORE TABLE (foo), (baz) FROM ('bar') AS OF SYSTEM TIME ('1') -- fully parenthetized +RESTORE TABLE foo, baz FROM _ AS OF SYSTEM TIME _ -- literals removed +RESTORE TABLE foo, baz FROM '_' AS OF SYSTEM TIME _ -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE TABLE _, _ FROM 'bar' AS OF SYSTEM TIME '1' -- identifiers removed + +parse +RESTORE DATABASE foo FROM 'bar' +---- +RESTORE DATABASE foo FROM 'bar' +RESTORE DATABASE foo FROM ('bar') -- fully parenthetized +RESTORE DATABASE foo FROM _ -- literals removed +RESTORE DATABASE foo FROM '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE DATABASE _ FROM 'bar' -- identifiers removed + +parse +RESTORE DATABASE foo FROM ($1) +---- +RESTORE DATABASE foo FROM $1 -- normalized! +RESTORE DATABASE foo FROM ($1) -- fully parenthetized +RESTORE DATABASE foo FROM $1 -- literals removed +RESTORE DATABASE _ FROM $1 -- identifiers removed + +parse +EXPLAIN RESTORE DATABASE foo FROM 'bar' +---- +EXPLAIN RESTORE DATABASE foo FROM 'bar' +EXPLAIN RESTORE DATABASE foo FROM ('bar') -- fully parenthetized +EXPLAIN RESTORE DATABASE foo FROM _ -- literals removed +EXPLAIN RESTORE DATABASE foo FROM '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +EXPLAIN RESTORE DATABASE _ FROM 'bar' -- identifiers removed + +parse +RESTORE DATABASE foo FROM bar +---- +RESTORE DATABASE foo FROM 'bar' -- normalized! +RESTORE DATABASE foo FROM ('bar') -- fully parenthetized +RESTORE DATABASE foo FROM _ -- literals removed +RESTORE DATABASE foo FROM '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE DATABASE _ FROM 'bar' -- identifiers removed + + +parse +RESTORE DATABASE foo, baz FROM 'bar' +---- +RESTORE DATABASE foo, baz FROM 'bar' +RESTORE DATABASE foo, baz FROM ('bar') -- fully parenthetized +RESTORE DATABASE foo, baz FROM _ -- literals removed +RESTORE DATABASE foo, baz FROM '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE DATABASE _, _ FROM 'bar' -- identifiers removed + +parse +RESTORE DATABASE foo, baz FROM 'bar' AS OF SYSTEM TIME '1' +---- +RESTORE DATABASE foo, baz FROM 'bar' AS OF SYSTEM TIME '1' +RESTORE DATABASE foo, baz FROM ('bar') AS OF SYSTEM TIME ('1') -- fully parenthetized +RESTORE DATABASE foo, baz FROM _ AS OF SYSTEM TIME _ -- literals removed +RESTORE DATABASE foo, baz FROM '_' AS OF SYSTEM TIME _ -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE DATABASE _, _ FROM 'bar' AS OF SYSTEM TIME '1' -- identifiers removed + +parse +RESTORE DATABASE foo FROM ($1, $2) +---- +RESTORE DATABASE foo FROM ($1, $2) +RESTORE DATABASE foo FROM (($1), ($2)) -- fully parenthetized +RESTORE DATABASE foo FROM ($1, $2) -- literals removed +RESTORE DATABASE _ FROM ($1, $2) -- identifiers removed + +parse +RESTORE DATABASE foo FROM ($1), ($2) +---- +RESTORE DATABASE foo FROM $1, $2 -- normalized! +RESTORE DATABASE foo FROM ($1), ($2) -- fully parenthetized +RESTORE DATABASE foo FROM $1, $2 -- literals removed +RESTORE DATABASE _ FROM $1, $2 -- identifiers removed + +parse +RESTORE DATABASE foo FROM ($1), ($2, $3) +---- +RESTORE DATABASE foo FROM $1, ($2, $3) -- normalized! +RESTORE DATABASE foo FROM ($1), (($2), ($3)) -- fully parenthetized +RESTORE DATABASE foo FROM $1, ($2, $3) -- literals removed +RESTORE DATABASE _ FROM $1, ($2, $3) -- identifiers removed + +parse +RESTORE DATABASE foo FROM ($1, $2), $3 +---- +RESTORE DATABASE foo FROM ($1, $2), $3 +RESTORE DATABASE foo FROM (($1), ($2)), ($3) -- fully parenthetized +RESTORE DATABASE foo FROM ($1, $2), $3 -- literals removed +RESTORE DATABASE _ FROM ($1, $2), $3 -- identifiers removed + +parse +RESTORE DATABASE foo FROM $1, ($2, $3) +---- +RESTORE DATABASE foo FROM $1, ($2, $3) +RESTORE DATABASE foo FROM ($1), (($2), ($3)) -- fully parenthetized +RESTORE DATABASE foo FROM $1, ($2, $3) -- literals removed +RESTORE DATABASE _ FROM $1, ($2, $3) -- identifiers removed + +parse +RESTORE DATABASE foo FROM ($1, $2), ($3, $4) +---- +RESTORE DATABASE foo FROM ($1, $2), ($3, $4) +RESTORE DATABASE foo FROM (($1), ($2)), (($3), ($4)) -- fully parenthetized +RESTORE DATABASE foo FROM ($1, $2), ($3, $4) -- literals removed +RESTORE DATABASE _ FROM ($1, $2), ($3, $4) -- identifiers removed + +parse +RESTORE DATABASE foo FROM ($1, $2), ($3, $4) AS OF SYSTEM TIME '1' +---- +RESTORE DATABASE foo FROM ($1, $2), ($3, $4) AS OF SYSTEM TIME '1' +RESTORE DATABASE foo FROM (($1), ($2)), (($3), ($4)) AS OF SYSTEM TIME ('1') -- fully parenthetized +RESTORE DATABASE foo FROM ($1, $2), ($3, $4) AS OF SYSTEM TIME _ -- literals removed +RESTORE DATABASE _ FROM ($1, $2), ($3, $4) AS OF SYSTEM TIME '1' -- identifiers removed + +parse +RESTORE FROM ($1, $2) +---- +RESTORE FROM ($1, $2) +RESTORE FROM (($1), ($2)) -- fully parenthetized +RESTORE FROM ($1, $2) -- literals removed +RESTORE FROM ($1, $2) -- identifiers removed + +parse +RESTORE FROM ($1, $2), $3 +---- +RESTORE FROM ($1, $2), $3 +RESTORE FROM (($1), ($2)), ($3) -- fully parenthetized +RESTORE FROM ($1, $2), $3 -- literals removed +RESTORE FROM ($1, $2), $3 -- identifiers removed + +parse +RESTORE FROM $1, ($2, $3) +---- +RESTORE FROM $1, ($2, $3) +RESTORE FROM ($1), (($2), ($3)) -- fully parenthetized +RESTORE FROM $1, ($2, $3) -- literals removed +RESTORE FROM $1, ($2, $3) -- identifiers removed + +parse +RESTORE FROM ($1, $2), ($3, $4) +---- +RESTORE FROM ($1, $2), ($3, $4) +RESTORE FROM (($1), ($2)), (($3), ($4)) -- fully parenthetized +RESTORE FROM ($1, $2), ($3, $4) -- literals removed +RESTORE FROM ($1, $2), ($3, $4) -- identifiers removed + +parse +RESTORE FROM ($1, $2), ($3, $4) AS OF SYSTEM TIME '1' +---- +RESTORE FROM ($1, $2), ($3, $4) AS OF SYSTEM TIME '1' +RESTORE FROM (($1), ($2)), (($3), ($4)) AS OF SYSTEM TIME ('1') -- fully parenthetized +RESTORE FROM ($1, $2), ($3, $4) AS OF SYSTEM TIME _ -- literals removed +RESTORE FROM ($1, $2), ($3, $4) AS OF SYSTEM TIME '1' -- identifiers removed + +parse +RESTORE FROM $1, $2, 'bar' +---- +RESTORE FROM $1, $2, 'bar' +RESTORE FROM ($1), ($2), ('bar') -- fully parenthetized +RESTORE FROM $1, $2, _ -- literals removed +RESTORE FROM $1, $2, '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE FROM $1, $2, 'bar' -- identifiers removed + +parse +RESTORE FROM $4 IN $1, $2, 'bar' +---- +RESTORE FROM $4 IN $1, $2, 'bar' +RESTORE FROM ($4) IN ($1), ($2), ('bar') -- fully parenthetized +RESTORE FROM $4 IN $1, $2, _ -- literals removed +RESTORE FROM $4 IN $1, $2, '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE FROM $4 IN $1, $2, 'bar' -- identifiers removed + +parse +RESTORE FROM $4 IN $1, $2, 'bar' AS OF SYSTEM TIME '1' WITH skip_missing_foreign_keys +---- +RESTORE FROM $4 IN $1, $2, 'bar' AS OF SYSTEM TIME '1' WITH skip_missing_foreign_keys +RESTORE FROM ($4) IN ($1), ($2), ('bar') AS OF SYSTEM TIME ('1') WITH skip_missing_foreign_keys -- fully parenthetized +RESTORE FROM $4 IN $1, $2, _ AS OF SYSTEM TIME _ WITH skip_missing_foreign_keys -- literals removed +RESTORE FROM $4 IN $1, $2, '_' AS OF SYSTEM TIME _ WITH skip_missing_foreign_keys -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE FROM $4 IN $1, $2, 'bar' AS OF SYSTEM TIME '1' WITH skip_missing_foreign_keys -- identifiers removed + +parse +RESTORE abc.xzy FROM 'a' WITH into_db = 'foo', skip_missing_foreign_keys +---- +RESTORE TABLE abc.xzy FROM 'a' WITH into_db = 'foo', skip_missing_foreign_keys -- normalized! +RESTORE TABLE (abc.xzy) FROM ('a') WITH into_db = ('foo'), skip_missing_foreign_keys -- fully parenthetized +RESTORE TABLE abc.xzy FROM _ WITH into_db = _, skip_missing_foreign_keys -- literals removed +RESTORE TABLE abc.xzy FROM '_' WITH into_db = '_', skip_missing_foreign_keys -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE TABLE _._ FROM 'a' WITH into_db = 'foo', skip_missing_foreign_keys -- identifiers removed + +parse +RESTORE FROM 'a' WITH into_db = 'foo', skip_missing_foreign_keys +---- +RESTORE FROM 'a' WITH into_db = 'foo', skip_missing_foreign_keys +RESTORE FROM ('a') WITH into_db = ('foo'), skip_missing_foreign_keys -- fully parenthetized +RESTORE FROM _ WITH into_db = _, skip_missing_foreign_keys -- literals removed +RESTORE FROM '_' WITH into_db = '_', skip_missing_foreign_keys -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE FROM 'a' WITH into_db = 'foo', skip_missing_foreign_keys -- identifiers removed + +parse +RESTORE foo FROM 'bar' WITH OPTIONS (encryption_passphrase='secret', into_db='baz', +skip_missing_foreign_keys, skip_missing_sequences, skip_missing_sequence_owners, skip_missing_views, detached) +---- +RESTORE TABLE foo FROM 'bar' WITH encryption_passphrase = 'secret', into_db = 'baz', skip_missing_foreign_keys, skip_missing_sequence_owners, skip_missing_sequences, skip_missing_views, detached -- normalized! +RESTORE TABLE (foo) FROM ('bar') WITH encryption_passphrase = ('secret'), into_db = ('baz'), skip_missing_foreign_keys, skip_missing_sequence_owners, skip_missing_sequences, skip_missing_views, detached -- fully parenthetized +RESTORE TABLE foo FROM _ WITH encryption_passphrase = _, into_db = _, skip_missing_foreign_keys, skip_missing_sequence_owners, skip_missing_sequences, skip_missing_views, detached -- literals removed +RESTORE TABLE foo FROM '_' WITH encryption_passphrase = '_', into_db = '_', skip_missing_foreign_keys, skip_missing_sequence_owners, skip_missing_sequences, skip_missing_views, detached -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE TABLE _ FROM 'bar' WITH encryption_passphrase = 'secret', into_db = 'baz', skip_missing_foreign_keys, skip_missing_sequence_owners, skip_missing_sequences, skip_missing_views, detached -- identifiers removed + +parse +RESTORE foo FROM 'bar' WITH ENCRYPTION_PASSPHRASE = 'secret', INTO_DB=baz, +SKIP_MISSING_FOREIGN_KEYS, SKIP_MISSING_SEQUENCES, SKIP_MISSING_SEQUENCE_OWNERS, SKIP_MISSING_VIEWS +---- +RESTORE TABLE foo FROM 'bar' WITH encryption_passphrase = 'secret', into_db = 'baz', skip_missing_foreign_keys, skip_missing_sequence_owners, skip_missing_sequences, skip_missing_views -- normalized! +RESTORE TABLE (foo) FROM ('bar') WITH encryption_passphrase = ('secret'), into_db = ('baz'), skip_missing_foreign_keys, skip_missing_sequence_owners, skip_missing_sequences, skip_missing_views -- fully parenthetized +RESTORE TABLE foo FROM _ WITH encryption_passphrase = _, into_db = _, skip_missing_foreign_keys, skip_missing_sequence_owners, skip_missing_sequences, skip_missing_views -- literals removed +RESTORE TABLE foo FROM '_' WITH encryption_passphrase = '_', into_db = '_', skip_missing_foreign_keys, skip_missing_sequence_owners, skip_missing_sequences, skip_missing_views -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE TABLE _ FROM 'bar' WITH encryption_passphrase = 'secret', into_db = 'baz', skip_missing_foreign_keys, skip_missing_sequence_owners, skip_missing_sequences, skip_missing_views -- identifiers removed + + +parse +RESTORE TENANT 36 FROM ($1, $2) AS OF SYSTEM TIME '1' +---- +RESTORE TENANT 36 FROM ($1, $2) AS OF SYSTEM TIME '1' +RESTORE TENANT 36 FROM (($1), ($2)) AS OF SYSTEM TIME ('1') -- fully parenthetized +RESTORE TENANT 36 FROM ($1, $2) AS OF SYSTEM TIME _ -- literals removed +RESTORE TENANT 36 FROM ($1, $2) AS OF SYSTEM TIME '1' -- identifiers removed + +parse +RESTORE TENANT 123 FROM REPLICATION STREAM FROM 'bar' +---- +RESTORE TENANT 123 FROM REPLICATION STREAM FROM 'bar' +RESTORE TENANT 123 FROM REPLICATION STREAM FROM ('bar') -- fully parenthetized +RESTORE TENANT 123 FROM REPLICATION STREAM FROM _ -- literals removed +RESTORE TENANT 123 FROM REPLICATION STREAM FROM '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE TENANT 123 FROM REPLICATION STREAM FROM 'bar' -- identifiers removed + +parse +RESTORE TENANT 123 FROM REPLICATION STREAM FROM $1 +---- +RESTORE TENANT 123 FROM REPLICATION STREAM FROM $1 +RESTORE TENANT 123 FROM REPLICATION STREAM FROM ($1) -- fully parenthetized +RESTORE TENANT 123 FROM REPLICATION STREAM FROM $1 -- literals removed +RESTORE TENANT 123 FROM REPLICATION STREAM FROM $1 -- identifiers removed + +parse +RESTORE TENANT 123 FROM REPLICATION STREAM FROM 'bar' AS OF SYSTEM TIME '1' +---- +RESTORE TENANT 123 FROM REPLICATION STREAM FROM 'bar' AS OF SYSTEM TIME '1' +RESTORE TENANT 123 FROM REPLICATION STREAM FROM ('bar') AS OF SYSTEM TIME ('1') -- fully parenthetized +RESTORE TENANT 123 FROM REPLICATION STREAM FROM _ AS OF SYSTEM TIME _ -- literals removed +RESTORE TENANT 123 FROM REPLICATION STREAM FROM '_' AS OF SYSTEM TIME _ -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE TENANT 123 FROM REPLICATION STREAM FROM 'bar' AS OF SYSTEM TIME '1' -- identifiers removed + +parse +RESTORE TENANT 123 FROM REPLICATION STREAM FROM $1 AS OF SYSTEM TIME '1' +---- +RESTORE TENANT 123 FROM REPLICATION STREAM FROM $1 AS OF SYSTEM TIME '1' +RESTORE TENANT 123 FROM REPLICATION STREAM FROM ($1) AS OF SYSTEM TIME ('1') -- fully parenthetized +RESTORE TENANT 123 FROM REPLICATION STREAM FROM $1 AS OF SYSTEM TIME _ -- literals removed +RESTORE TENANT 123 FROM REPLICATION STREAM FROM $1 AS OF SYSTEM TIME '1' -- identifiers removed + +parse +BACKUP TABLE foo TO 'bar' WITH revision_history, detached +---- +BACKUP TABLE foo TO 'bar' WITH revision_history, detached +BACKUP TABLE (foo) TO ('bar') WITH revision_history, detached -- fully parenthetized +BACKUP TABLE foo TO _ WITH revision_history, detached -- literals removed +BACKUP TABLE foo TO '_' WITH revision_history, detached -- UNEXPECTED REPARSED AST WITHOUT LITERALS +BACKUP TABLE _ TO 'bar' WITH revision_history, detached -- identifiers removed + +parse +RESTORE TABLE foo FROM 'bar' WITH skip_missing_foreign_keys, skip_missing_sequences, detached +---- +RESTORE TABLE foo FROM 'bar' WITH skip_missing_foreign_keys, skip_missing_sequences, detached +RESTORE TABLE (foo) FROM ('bar') WITH skip_missing_foreign_keys, skip_missing_sequences, detached -- fully parenthetized +RESTORE TABLE foo FROM _ WITH skip_missing_foreign_keys, skip_missing_sequences, detached -- literals removed +RESTORE TABLE foo FROM '_' WITH skip_missing_foreign_keys, skip_missing_sequences, detached -- UNEXPECTED REPARSED AST WITHOUT LITERALS +RESTORE TABLE _ FROM 'bar' WITH skip_missing_foreign_keys, skip_missing_sequences, detached -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/begin_commit b/pkg/sql/parser/testdata/parse/begin_commit new file mode 100644 index 000000000000..44399961ab5e --- /dev/null +++ b/pkg/sql/parser/testdata/parse/begin_commit @@ -0,0 +1,263 @@ +parse +BEGIN TRANSACTION +---- +BEGIN TRANSACTION +BEGIN TRANSACTION -- fully parenthetized +BEGIN TRANSACTION -- literals removed +BEGIN TRANSACTION -- identifiers removed + +parse +BEGIN +---- +BEGIN TRANSACTION -- normalized! +BEGIN TRANSACTION -- fully parenthetized +BEGIN TRANSACTION -- literals removed +BEGIN TRANSACTION -- identifiers removed + +parse +START TRANSACTION +---- +BEGIN TRANSACTION -- normalized! +BEGIN TRANSACTION -- fully parenthetized +BEGIN TRANSACTION -- literals removed +BEGIN TRANSACTION -- identifiers removed + +parse +BEGIN TRANSACTION READ ONLY +---- +BEGIN TRANSACTION READ ONLY +BEGIN TRANSACTION READ ONLY -- fully parenthetized +BEGIN TRANSACTION READ ONLY -- literals removed +BEGIN TRANSACTION READ ONLY -- identifiers removed + +parse +BEGIN TRANSACTION READ WRITE +---- +BEGIN TRANSACTION READ WRITE +BEGIN TRANSACTION READ WRITE -- fully parenthetized +BEGIN TRANSACTION READ WRITE -- literals removed +BEGIN TRANSACTION READ WRITE -- identifiers removed + +parse +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE +---- +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE -- fully parenthetized +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE -- literals removed +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE -- identifiers removed + +parse +BEGIN TRANSACTION PRIORITY LOW +---- +BEGIN TRANSACTION PRIORITY LOW +BEGIN TRANSACTION PRIORITY LOW -- fully parenthetized +BEGIN TRANSACTION PRIORITY LOW -- literals removed +BEGIN TRANSACTION PRIORITY LOW -- identifiers removed + +parse +BEGIN TRANSACTION PRIORITY NORMAL +---- +BEGIN TRANSACTION PRIORITY NORMAL +BEGIN TRANSACTION PRIORITY NORMAL -- fully parenthetized +BEGIN TRANSACTION PRIORITY NORMAL -- literals removed +BEGIN TRANSACTION PRIORITY NORMAL -- identifiers removed + +parse +BEGIN TRANSACTION PRIORITY HIGH +---- +BEGIN TRANSACTION PRIORITY HIGH +BEGIN TRANSACTION PRIORITY HIGH -- fully parenthetized +BEGIN TRANSACTION PRIORITY HIGH -- literals removed +BEGIN TRANSACTION PRIORITY HIGH -- identifiers removed + +parse +BEGIN TRANSACTION AS OF SYSTEM TIME '2018-12-18' +---- +BEGIN TRANSACTION AS OF SYSTEM TIME '2018-12-18' +BEGIN TRANSACTION AS OF SYSTEM TIME ('2018-12-18') -- fully parenthetized +BEGIN TRANSACTION AS OF SYSTEM TIME _ -- literals removed +BEGIN TRANSACTION AS OF SYSTEM TIME '2018-12-18' -- identifiers removed + +parse +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, AS OF SYSTEM TIME '2018-12-18' +---- +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, AS OF SYSTEM TIME '2018-12-18' +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, AS OF SYSTEM TIME ('2018-12-18') -- fully parenthetized +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, AS OF SYSTEM TIME _ -- literals removed +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, AS OF SYSTEM TIME '2018-12-18' -- identifiers removed + +parse +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY LOW, 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, AS OF SYSTEM TIME ('2018-12-18') -- fully parenthetized +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY LOW, AS OF SYSTEM TIME _ -- literals removed +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY LOW, AS OF SYSTEM TIME '2018-12-18' -- identifiers removed + +parse +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY LOW, READ ONLY, AS OF SYSTEM TIME '-1ns' +---- +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY LOW, READ ONLY, AS OF SYSTEM TIME '-1ns' +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY LOW, READ ONLY, AS OF SYSTEM TIME ('-1ns') -- fully parenthetized +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY LOW, READ ONLY, AS OF SYSTEM TIME _ -- literals removed +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY LOW, READ ONLY, AS OF SYSTEM TIME '-1ns' -- identifiers removed + +parse +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH +---- +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH -- fully parenthetized +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH -- literals removed +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH -- identifiers removed + +parse +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH, READ WRITE +---- +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH, READ WRITE +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH, READ WRITE -- fully parenthetized +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH, READ WRITE -- literals removed +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH, READ WRITE -- identifiers removed + +parse +BEGIN TRANSACTION PRIORITY LOW, ISOLATION LEVEL SNAPSHOT +---- +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY LOW -- normalized! +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY LOW -- fully parenthetized +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY LOW -- literals removed +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY LOW -- identifiers removed + +parse +COMMIT TRANSACTION +---- +COMMIT TRANSACTION +COMMIT TRANSACTION -- fully parenthetized +COMMIT TRANSACTION -- literals removed +COMMIT TRANSACTION -- identifiers removed + +parse +COMMIT +---- +COMMIT TRANSACTION -- normalized! +COMMIT TRANSACTION -- fully parenthetized +COMMIT TRANSACTION -- literals removed +COMMIT TRANSACTION -- identifiers removed + +parse +END +---- +COMMIT TRANSACTION -- normalized! +COMMIT TRANSACTION -- fully parenthetized +COMMIT TRANSACTION -- literals removed +COMMIT TRANSACTION -- identifiers removed + +parse +ROLLBACK TRANSACTION +---- +ROLLBACK TRANSACTION +ROLLBACK TRANSACTION -- fully parenthetized +ROLLBACK TRANSACTION -- literals removed +ROLLBACK TRANSACTION -- identifiers removed + +parse +SAVEPOINT foo +---- +SAVEPOINT foo +SAVEPOINT foo -- fully parenthetized +SAVEPOINT foo -- literals removed +SAVEPOINT _ -- identifiers removed + +parse +SAVEPOINT "foo bar" +---- +SAVEPOINT "foo bar" +SAVEPOINT "foo bar" -- fully parenthetized +SAVEPOINT "foo bar" -- literals removed +SAVEPOINT _ -- identifiers removed + +parse +RELEASE foo +---- +RELEASE SAVEPOINT foo -- normalized! +RELEASE SAVEPOINT foo -- fully parenthetized +RELEASE SAVEPOINT foo -- literals removed +RELEASE SAVEPOINT _ -- identifiers removed + +parse +RELEASE SAVEPOINT foo +---- +RELEASE SAVEPOINT foo +RELEASE SAVEPOINT foo -- fully parenthetized +RELEASE SAVEPOINT foo -- literals removed +RELEASE SAVEPOINT _ -- identifiers removed + +parse +ROLLBACK +---- +ROLLBACK TRANSACTION -- normalized! +ROLLBACK TRANSACTION -- fully parenthetized +ROLLBACK TRANSACTION -- literals removed +ROLLBACK TRANSACTION -- identifiers removed + +parse +ROLLBACK TRANSACTION +---- +ROLLBACK TRANSACTION +ROLLBACK TRANSACTION -- fully parenthetized +ROLLBACK TRANSACTION -- literals removed +ROLLBACK TRANSACTION -- identifiers removed + +parse +ROLLBACK TO foo +---- +ROLLBACK TRANSACTION TO SAVEPOINT foo -- normalized! +ROLLBACK TRANSACTION TO SAVEPOINT foo -- fully parenthetized +ROLLBACK TRANSACTION TO SAVEPOINT foo -- literals removed +ROLLBACK TRANSACTION TO SAVEPOINT _ -- identifiers removed + +parse +ROLLBACK TO SAVEPOINT foo +---- +ROLLBACK TRANSACTION TO SAVEPOINT foo -- normalized! +ROLLBACK TRANSACTION TO SAVEPOINT foo -- fully parenthetized +ROLLBACK TRANSACTION TO SAVEPOINT foo -- literals removed +ROLLBACK TRANSACTION TO SAVEPOINT _ -- identifiers removed + +parse +ROLLBACK TRANSACTION TO foo +---- +ROLLBACK TRANSACTION TO SAVEPOINT foo -- normalized! +ROLLBACK TRANSACTION TO SAVEPOINT foo -- fully parenthetized +ROLLBACK TRANSACTION TO SAVEPOINT foo -- literals removed +ROLLBACK TRANSACTION TO SAVEPOINT _ -- identifiers removed + +parse +ROLLBACK TRANSACTION TO SAVEPOINT foo +---- +ROLLBACK TRANSACTION TO SAVEPOINT foo +ROLLBACK TRANSACTION TO SAVEPOINT foo -- fully parenthetized +ROLLBACK TRANSACTION TO SAVEPOINT foo -- literals removed +ROLLBACK TRANSACTION TO SAVEPOINT _ -- identifiers removed + +parse +ABORT TRANSACTION +---- +ROLLBACK TRANSACTION -- normalized! +ROLLBACK TRANSACTION -- fully parenthetized +ROLLBACK TRANSACTION -- literals removed +ROLLBACK TRANSACTION -- identifiers removed + +parse +ABORT WORK +---- +ROLLBACK TRANSACTION -- normalized! +ROLLBACK TRANSACTION -- fully parenthetized +ROLLBACK TRANSACTION -- literals removed +ROLLBACK TRANSACTION -- identifiers removed + +parse +ABORT +---- +ROLLBACK TRANSACTION -- normalized! +ROLLBACK TRANSACTION -- fully parenthetized +ROLLBACK TRANSACTION -- literals removed +ROLLBACK TRANSACTION -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/changefeed b/pkg/sql/parser/testdata/parse/changefeed new file mode 100644 index 000000000000..90e640ff3093 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/changefeed @@ -0,0 +1,66 @@ +parse +EXPERIMENTAL CHANGEFEED FOR TABLE foo +---- +EXPERIMENTAL CHANGEFEED FOR TABLE foo +EXPERIMENTAL CHANGEFEED FOR TABLE (foo) -- fully parenthetized +EXPERIMENTAL CHANGEFEED FOR TABLE foo -- literals removed +EXPERIMENTAL CHANGEFEED FOR TABLE _ -- identifiers removed + +parse +EXPLAIN CREATE CHANGEFEED FOR TABLE foo INTO 'sink' +---- +EXPLAIN CREATE CHANGEFEED FOR TABLE foo INTO 'sink' +EXPLAIN CREATE CHANGEFEED FOR TABLE (foo) INTO ('sink') -- fully parenthetized +EXPLAIN CREATE CHANGEFEED FOR TABLE foo INTO _ -- literals removed +EXPLAIN CREATE CHANGEFEED FOR TABLE foo INTO '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +EXPLAIN CREATE CHANGEFEED FOR TABLE _ INTO 'sink' -- identifiers removed + +parse +CREATE CHANGEFEED FOR foo INTO 'sink' +---- +CREATE CHANGEFEED FOR TABLE foo INTO 'sink' -- normalized! +CREATE CHANGEFEED FOR TABLE (foo) INTO ('sink') -- fully parenthetized +CREATE CHANGEFEED FOR TABLE foo INTO _ -- literals removed +CREATE CHANGEFEED FOR TABLE foo INTO '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +CREATE CHANGEFEED FOR TABLE _ INTO 'sink' -- identifiers removed + +parse +CREATE CHANGEFEED FOR TABLE foo INTO sink +---- +CREATE CHANGEFEED FOR TABLE foo INTO 'sink' -- normalized! +CREATE CHANGEFEED FOR TABLE (foo) INTO ('sink') -- fully parenthetized +CREATE CHANGEFEED FOR TABLE foo INTO _ -- literals removed +CREATE CHANGEFEED FOR TABLE foo INTO '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +CREATE CHANGEFEED FOR TABLE _ INTO 'sink' -- identifiers removed + +parse +CREATE CHANGEFEED FOR TABLE foo, db.bar, schema.db.foo INTO 'sink' +---- +CREATE CHANGEFEED FOR TABLE foo, db.bar, schema.db.foo INTO 'sink' +CREATE CHANGEFEED FOR TABLE (foo), (db.bar), (schema.db.foo) INTO ('sink') -- fully parenthetized +CREATE CHANGEFEED FOR TABLE foo, db.bar, schema.db.foo INTO _ -- literals removed +CREATE CHANGEFEED FOR TABLE foo, db.bar, schema.db.foo INTO '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +CREATE CHANGEFEED FOR TABLE _, _._, _._._ INTO 'sink' -- identifiers removed + +parse +CREATE CHANGEFEED FOR TABLE foo INTO 'sink' +---- +CREATE CHANGEFEED FOR TABLE foo INTO 'sink' +CREATE CHANGEFEED FOR TABLE (foo) INTO ('sink') -- fully parenthetized +CREATE CHANGEFEED FOR TABLE foo INTO _ -- literals removed +CREATE CHANGEFEED FOR TABLE foo INTO '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +CREATE CHANGEFEED FOR TABLE _ INTO 'sink' -- identifiers removed + +## TODO(dan): Implement: +## CREATE CHANGEFEED FOR TABLE foo VALUES FROM (1) TO (2) INTO 'sink' +## CREATE CHANGEFEED FOR TABLE foo PARTITION bar, baz INTO 'sink' +## CREATE CHANGEFEED FOR DATABASE foo INTO 'sink' + +parse +CREATE CHANGEFEED FOR TABLE foo INTO 'sink' WITH bar = 'baz' +---- +CREATE CHANGEFEED FOR TABLE foo INTO 'sink' WITH bar = 'baz' +CREATE CHANGEFEED FOR TABLE (foo) INTO ('sink') WITH bar = ('baz') -- fully parenthetized +CREATE CHANGEFEED FOR TABLE foo INTO _ WITH bar = _ -- literals removed +CREATE CHANGEFEED FOR TABLE foo INTO '_' WITH bar = '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +CREATE CHANGEFEED FOR TABLE _ INTO 'sink' WITH _ = 'baz' -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/comment b/pkg/sql/parser/testdata/parse/comment new file mode 100644 index 000000000000..02be16afa6a9 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/comment @@ -0,0 +1,86 @@ + +parse +COMMENT ON COLUMN a.b IS 'a' +---- +COMMENT ON COLUMN a.b IS 'a' +(COMMENT ON COLUMN (a.b) IS 'a') -- fully parenthetized +COMMENT ON COLUMN a.b IS _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +COMMENT ON COLUMN _._ IS 'a' -- identifiers removed + +parse +COMMENT ON COLUMN a.b IS NULL +---- +COMMENT ON COLUMN a.b IS NULL +(COMMENT ON COLUMN (a.b) IS NULL) -- fully parenthetized +COMMENT ON COLUMN a.b IS NULL -- literals removed +COMMENT ON COLUMN _._ IS NULL -- identifiers removed + +parse +COMMENT ON COLUMN a.b.c IS 'a' +---- +COMMENT ON COLUMN a.b.c IS 'a' +(COMMENT ON COLUMN (a.b.c) IS 'a') -- fully parenthetized +COMMENT ON COLUMN a.b.c IS _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +COMMENT ON COLUMN _._._ IS 'a' -- identifiers removed + +parse +COMMENT ON COLUMN a.b.c.d IS 'a' +---- +COMMENT ON COLUMN a.b.c.d IS 'a' +(COMMENT ON COLUMN (a.b.c.d) IS 'a') -- fully parenthetized +COMMENT ON COLUMN a.b.c.d IS _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +COMMENT ON COLUMN _._._._ IS 'a' -- identifiers removed + +parse +COMMENT ON DATABASE foo IS 'a' +---- +COMMENT ON DATABASE foo IS 'a' +COMMENT ON DATABASE foo IS 'a' -- fully parenthetized +COMMENT ON DATABASE foo IS _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +COMMENT ON DATABASE _ IS 'a' -- identifiers removed + +parse +COMMENT ON DATABASE foo IS NULL +---- +COMMENT ON DATABASE foo IS NULL +COMMENT ON DATABASE foo IS NULL -- fully parenthetized +COMMENT ON DATABASE foo IS NULL -- literals removed +COMMENT ON DATABASE _ IS NULL -- identifiers removed + +parse +COMMENT ON INDEX foo IS 'a' +---- +COMMENT ON INDEX foo IS 'a' +COMMENT ON INDEX foo IS 'a' -- fully parenthetized +COMMENT ON INDEX foo IS _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +COMMENT ON INDEX _ IS 'a' -- identifiers removed + +parse +COMMENT ON INDEX foo IS NULL +---- +COMMENT ON INDEX foo IS NULL +COMMENT ON INDEX foo IS NULL -- fully parenthetized +COMMENT ON INDEX foo IS NULL -- literals removed +COMMENT ON INDEX _ IS NULL -- identifiers removed + +parse +COMMENT ON TABLE foo IS 'a' +---- +COMMENT ON TABLE foo IS 'a' +COMMENT ON TABLE foo IS 'a' -- fully parenthetized +COMMENT ON TABLE foo IS _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +COMMENT ON TABLE _ IS 'a' -- identifiers removed + +parse +COMMENT ON TABLE foo IS NULL +---- +COMMENT ON TABLE foo IS NULL +COMMENT ON TABLE foo IS NULL -- fully parenthetized +COMMENT ON TABLE foo IS NULL -- literals removed +COMMENT ON TABLE _ IS NULL -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/common_table_exprs b/pkg/sql/parser/testdata/parse/common_table_exprs new file mode 100644 index 000000000000..da2e39ef1e1c --- /dev/null +++ b/pkg/sql/parser/testdata/parse/common_table_exprs @@ -0,0 +1,63 @@ +parse +WITH cte AS (SELECT 1) SELECT * FROM cte +---- +WITH cte AS (SELECT 1) SELECT * FROM cte +WITH cte AS (SELECT (1)) SELECT (*) FROM cte -- fully parenthetized +WITH cte AS (SELECT _) SELECT * FROM cte -- literals removed +WITH _ AS (SELECT 1) SELECT * FROM _ -- identifiers removed + +parse +WITH cte (x) AS (INSERT INTO abc VALUES (1, 2)), cte2 (y) AS (SELECT x + 1 FROM cte) SELECT * FROM cte, cte2 +---- +WITH cte (x) AS (INSERT INTO abc VALUES (1, 2)), cte2 (y) AS (SELECT x + 1 FROM cte) SELECT * FROM cte, cte2 +WITH cte (x) AS (INSERT INTO abc VALUES ((1), (2))), cte2 (y) AS (SELECT ((x) + (1)) FROM cte) SELECT (*) FROM cte, cte2 -- fully parenthetized +WITH cte (x) AS (INSERT INTO abc VALUES (_, _)), cte2 (y) AS (SELECT x + _ FROM cte) SELECT * FROM cte, cte2 -- literals removed +WITH _ (_) AS (INSERT INTO _ VALUES (1, 2)), _ (_) AS (SELECT _ + 1 FROM _) SELECT * FROM _, _ -- identifiers removed + +parse +WITH RECURSIVE cte (x) AS (SELECT 1), cte2 (y) AS (SELECT x + 1 FROM cte) SELECT 1 +---- +WITH RECURSIVE cte (x) AS (SELECT 1), cte2 (y) AS (SELECT x + 1 FROM cte) SELECT 1 +WITH RECURSIVE cte (x) AS (SELECT (1)), cte2 (y) AS (SELECT ((x) + (1)) FROM cte) SELECT (1) -- fully parenthetized +WITH RECURSIVE cte (x) AS (SELECT _), cte2 (y) AS (SELECT x + _ FROM cte) SELECT _ -- literals removed +WITH RECURSIVE _ (_) AS (SELECT 1), _ (_) AS (SELECT _ + 1 FROM _) SELECT 1 -- identifiers removed + +parse +WITH cte AS MATERIALIZED (SELECT 1) SELECT * FROM cte +---- +WITH cte AS MATERIALIZED (SELECT 1) SELECT * FROM cte +WITH cte AS MATERIALIZED (SELECT (1)) SELECT (*) FROM cte -- fully parenthetized +WITH cte AS MATERIALIZED (SELECT _) SELECT * FROM cte -- literals removed +WITH _ AS MATERIALIZED (SELECT 1) SELECT * FROM _ -- identifiers removed + +parse +WITH RECURSIVE cte AS MATERIALIZED (SELECT 1) SELECT * FROM cte +---- +WITH RECURSIVE cte AS MATERIALIZED (SELECT 1) SELECT * FROM cte +WITH RECURSIVE cte AS MATERIALIZED (SELECT (1)) SELECT (*) FROM cte -- fully parenthetized +WITH RECURSIVE cte AS MATERIALIZED (SELECT _) SELECT * FROM cte -- literals removed +WITH RECURSIVE _ AS MATERIALIZED (SELECT 1) SELECT * FROM _ -- identifiers removed + +parse +WITH cte AS NOT MATERIALIZED (SELECT 1) SELECT * FROM cte +---- +WITH cte AS NOT MATERIALIZED (SELECT 1) SELECT * FROM cte +WITH cte AS NOT MATERIALIZED (SELECT (1)) SELECT (*) FROM cte -- fully parenthetized +WITH cte AS NOT MATERIALIZED (SELECT _) SELECT * FROM cte -- literals removed +WITH _ AS NOT MATERIALIZED (SELECT 1) SELECT * FROM _ -- identifiers removed + +parse +WITH cte (x) AS MATERIALIZED (INSERT INTO abc VALUES (1, 2)), cte2 (y) AS NOT MATERIALIZED (SELECT x + 1 FROM cte) SELECT * FROM cte, cte2 +---- +WITH cte (x) AS MATERIALIZED (INSERT INTO abc VALUES (1, 2)), cte2 (y) AS NOT MATERIALIZED (SELECT x + 1 FROM cte) SELECT * FROM cte, cte2 +WITH cte (x) AS MATERIALIZED (INSERT INTO abc VALUES ((1), (2))), cte2 (y) AS NOT MATERIALIZED (SELECT ((x) + (1)) FROM cte) SELECT (*) FROM cte, cte2 -- fully parenthetized +WITH cte (x) AS MATERIALIZED (INSERT INTO abc VALUES (_, _)), cte2 (y) AS NOT MATERIALIZED (SELECT x + _ FROM cte) SELECT * FROM cte, cte2 -- literals removed +WITH _ (_) AS MATERIALIZED (INSERT INTO _ VALUES (1, 2)), _ (_) AS NOT MATERIALIZED (SELECT _ + 1 FROM _) SELECT * FROM _, _ -- identifiers removed + +parse +WITH RECURSIVE cte (x) AS MATERIALIZED (INSERT INTO abc VALUES (1, 2)), cte2 (y) AS NOT MATERIALIZED (SELECT x + 1 FROM cte) SELECT * FROM cte, cte2 +---- +WITH RECURSIVE cte (x) AS MATERIALIZED (INSERT INTO abc VALUES (1, 2)), cte2 (y) AS NOT MATERIALIZED (SELECT x + 1 FROM cte) SELECT * FROM cte, cte2 +WITH RECURSIVE cte (x) AS MATERIALIZED (INSERT INTO abc VALUES ((1), (2))), cte2 (y) AS NOT MATERIALIZED (SELECT ((x) + (1)) FROM cte) SELECT (*) FROM cte, cte2 -- fully parenthetized +WITH RECURSIVE cte (x) AS MATERIALIZED (INSERT INTO abc VALUES (_, _)), cte2 (y) AS NOT MATERIALIZED (SELECT x + _ FROM cte) SELECT * FROM cte, cte2 -- literals removed +WITH RECURSIVE _ (_) AS MATERIALIZED (INSERT INTO _ VALUES (1, 2)), _ (_) AS NOT MATERIALIZED (SELECT _ + 1 FROM _) SELECT * FROM _, _ -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/control_job b/pkg/sql/parser/testdata/parse/control_job new file mode 100644 index 000000000000..17750a6b9b89 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/control_job @@ -0,0 +1,503 @@ +parse +CANCEL JOBS SELECT a +---- +CANCEL JOBS SELECT a +CANCEL JOBS SELECT (a) -- fully parenthetized +CANCEL JOBS SELECT a -- literals removed +CANCEL JOBS SELECT _ -- identifiers removed + +parse +EXPLAIN CANCEL JOBS SELECT a +---- +EXPLAIN CANCEL JOBS SELECT a +EXPLAIN CANCEL JOBS SELECT (a) -- fully parenthetized +EXPLAIN CANCEL JOBS SELECT a -- literals removed +EXPLAIN CANCEL JOBS SELECT _ -- identifiers removed + +parse +RESUME JOBS SELECT a +---- +RESUME JOBS SELECT a +RESUME JOBS SELECT (a) -- fully parenthetized +RESUME JOBS SELECT a -- literals removed +RESUME JOBS SELECT _ -- identifiers removed + +parse +EXPLAIN RESUME JOBS SELECT a +---- +EXPLAIN RESUME JOBS SELECT a +EXPLAIN RESUME JOBS SELECT (a) -- fully parenthetized +EXPLAIN RESUME JOBS SELECT a -- literals removed +EXPLAIN RESUME JOBS SELECT _ -- identifiers removed + +parse +PAUSE JOBS SELECT a +---- +PAUSE JOBS SELECT a +PAUSE JOBS SELECT (a) -- fully parenthetized +PAUSE JOBS SELECT a -- literals removed +PAUSE JOBS SELECT _ -- identifiers removed + +parse +EXPLAIN PAUSE JOBS SELECT a +---- +EXPLAIN PAUSE JOBS SELECT a +EXPLAIN PAUSE JOBS SELECT (a) -- fully parenthetized +EXPLAIN PAUSE JOBS SELECT a -- literals removed +EXPLAIN PAUSE JOBS SELECT _ -- identifiers removed + +parse +PAUSE SCHEDULES SELECT a +---- +PAUSE SCHEDULES SELECT a +PAUSE SCHEDULES SELECT (a) -- fully parenthetized +PAUSE SCHEDULES SELECT a -- literals removed +PAUSE SCHEDULES SELECT _ -- identifiers removed + +parse +EXPLAIN PAUSE SCHEDULES SELECT a +---- +EXPLAIN PAUSE SCHEDULES SELECT a +EXPLAIN PAUSE SCHEDULES SELECT (a) -- fully parenthetized +EXPLAIN PAUSE SCHEDULES SELECT a -- literals removed +EXPLAIN PAUSE SCHEDULES SELECT _ -- identifiers removed + +parse +RESUME SCHEDULES SELECT a +---- +RESUME SCHEDULES SELECT a +RESUME SCHEDULES SELECT (a) -- fully parenthetized +RESUME SCHEDULES SELECT a -- literals removed +RESUME SCHEDULES SELECT _ -- identifiers removed + +parse +EXPLAIN RESUME SCHEDULES SELECT a +---- +EXPLAIN RESUME SCHEDULES SELECT a +EXPLAIN RESUME SCHEDULES SELECT (a) -- fully parenthetized +EXPLAIN RESUME SCHEDULES SELECT a -- literals removed +EXPLAIN RESUME SCHEDULES SELECT _ -- identifiers removed + +parse +RESUME SCHEDULE a +---- +RESUME SCHEDULES VALUES (a) -- normalized! +RESUME SCHEDULES VALUES ((a)) -- fully parenthetized +RESUME SCHEDULES VALUES (a) -- literals removed +RESUME SCHEDULES VALUES (_) -- identifiers removed + +parse +EXPLAIN RESUME SCHEDULE a +---- +EXPLAIN RESUME SCHEDULES VALUES (a) -- normalized! +EXPLAIN RESUME SCHEDULES VALUES ((a)) -- fully parenthetized +EXPLAIN RESUME SCHEDULES VALUES (a) -- literals removed +EXPLAIN RESUME SCHEDULES VALUES (_) -- identifiers removed + + +parse +DROP SCHEDULES SELECT a +---- +DROP SCHEDULES SELECT a +DROP SCHEDULES SELECT (a) -- fully parenthetized +DROP SCHEDULES SELECT a -- literals removed +DROP SCHEDULES SELECT _ -- identifiers removed + +parse +EXPLAIN DROP SCHEDULES SELECT a +---- +EXPLAIN DROP SCHEDULES SELECT a +EXPLAIN DROP SCHEDULES SELECT (a) -- fully parenthetized +EXPLAIN DROP SCHEDULES SELECT a -- literals removed +EXPLAIN DROP SCHEDULES SELECT _ -- identifiers removed + +parse +DROP SCHEDULE a +---- +DROP SCHEDULES VALUES (a) -- normalized! +DROP SCHEDULES VALUES ((a)) -- fully parenthetized +DROP SCHEDULES VALUES (a) -- literals removed +DROP SCHEDULES VALUES (_) -- identifiers removed + +parse +EXPLAIN DROP SCHEDULE a +---- +EXPLAIN DROP SCHEDULES VALUES (a) -- normalized! +EXPLAIN DROP SCHEDULES VALUES ((a)) -- fully parenthetized +EXPLAIN DROP SCHEDULES VALUES (a) -- literals removed +EXPLAIN DROP SCHEDULES VALUES (_) -- identifiers removed + +parse +SHOW JOB a +---- +SHOW JOBS VALUES (a) -- normalized! +SHOW JOBS VALUES ((a)) -- fully parenthetized +SHOW JOBS VALUES (a) -- literals removed +SHOW JOBS VALUES (_) -- identifiers removed + +parse +EXPLAIN SHOW JOB a +---- +EXPLAIN SHOW JOBS VALUES (a) -- normalized! +EXPLAIN SHOW JOBS VALUES ((a)) -- fully parenthetized +EXPLAIN SHOW JOBS VALUES (a) -- literals removed +EXPLAIN SHOW JOBS VALUES (_) -- identifiers removed + +parse +SHOW JOBS SELECT a +---- +SHOW JOBS SELECT a +SHOW JOBS SELECT (a) -- fully parenthetized +SHOW JOBS SELECT a -- literals removed +SHOW JOBS SELECT _ -- identifiers removed + +parse +EXPLAIN SHOW JOBS SELECT a +---- +EXPLAIN SHOW JOBS SELECT a +EXPLAIN SHOW JOBS SELECT (a) -- fully parenthetized +EXPLAIN SHOW JOBS SELECT a -- literals removed +EXPLAIN SHOW JOBS SELECT _ -- identifiers removed + +parse +SHOW JOB WHEN COMPLETE a +---- +SHOW JOBS WHEN COMPLETE VALUES (a) -- normalized! +SHOW JOBS WHEN COMPLETE VALUES ((a)) -- fully parenthetized +SHOW JOBS WHEN COMPLETE VALUES (a) -- literals removed +SHOW JOBS WHEN COMPLETE VALUES (_) -- identifiers removed + +parse +EXPLAIN SHOW JOB WHEN COMPLETE a +---- +EXPLAIN SHOW JOBS WHEN COMPLETE VALUES (a) -- normalized! +EXPLAIN SHOW JOBS WHEN COMPLETE VALUES ((a)) -- fully parenthetized +EXPLAIN SHOW JOBS WHEN COMPLETE VALUES (a) -- literals removed +EXPLAIN SHOW JOBS WHEN COMPLETE VALUES (_) -- identifiers removed + + +parse +SHOW JOBS WHEN COMPLETE SELECT a +---- +SHOW JOBS WHEN COMPLETE SELECT a +SHOW JOBS WHEN COMPLETE SELECT (a) -- fully parenthetized +SHOW JOBS WHEN COMPLETE SELECT a -- literals removed +SHOW JOBS WHEN COMPLETE SELECT _ -- identifiers removed + +parse +EXPLAIN SHOW JOBS WHEN COMPLETE SELECT a +---- +EXPLAIN SHOW JOBS WHEN COMPLETE SELECT a +EXPLAIN SHOW JOBS WHEN COMPLETE SELECT (a) -- fully parenthetized +EXPLAIN SHOW JOBS WHEN COMPLETE SELECT a -- literals removed +EXPLAIN SHOW JOBS WHEN COMPLETE SELECT _ -- identifiers removed + +parse +PAUSE JOBS FOR SCHEDULES SELECT 1 +---- +PAUSE JOBS FOR SCHEDULES SELECT 1 +PAUSE JOBS FOR SCHEDULES SELECT (1) -- fully parenthetized +PAUSE JOBS FOR SCHEDULES SELECT _ -- literals removed +PAUSE JOBS FOR SCHEDULES SELECT 1 -- identifiers removed + +parse +EXPLAIN PAUSE JOBS FOR SCHEDULES SELECT 1 +---- +EXPLAIN PAUSE JOBS FOR SCHEDULES SELECT 1 +EXPLAIN PAUSE JOBS FOR SCHEDULES SELECT (1) -- fully parenthetized +EXPLAIN PAUSE JOBS FOR SCHEDULES SELECT _ -- literals removed +EXPLAIN PAUSE JOBS FOR SCHEDULES SELECT 1 -- identifiers removed + +parse +PAUSE JOB a +---- +PAUSE JOBS VALUES (a) -- normalized! +PAUSE JOBS VALUES ((a)) -- fully parenthetized +PAUSE JOBS VALUES (a) -- literals removed +PAUSE JOBS VALUES (_) -- identifiers removed + +parse +EXPLAIN PAUSE JOB a +---- +EXPLAIN PAUSE JOBS VALUES (a) -- normalized! +EXPLAIN PAUSE JOBS VALUES ((a)) -- fully parenthetized +EXPLAIN PAUSE JOBS VALUES (a) -- literals removed +EXPLAIN PAUSE JOBS VALUES (_) -- identifiers removed + +parse +PAUSE JOBS FOR SCHEDULE a +---- +PAUSE JOBS FOR SCHEDULES VALUES (a) -- normalized! +PAUSE JOBS FOR SCHEDULES VALUES ((a)) -- fully parenthetized +PAUSE JOBS FOR SCHEDULES VALUES (a) -- literals removed +PAUSE JOBS FOR SCHEDULES VALUES (_) -- identifiers removed + +parse +EXPLAIN PAUSE JOBS FOR SCHEDULE a +---- +EXPLAIN PAUSE JOBS FOR SCHEDULES VALUES (a) -- normalized! +EXPLAIN PAUSE JOBS FOR SCHEDULES VALUES ((a)) -- fully parenthetized +EXPLAIN PAUSE JOBS FOR SCHEDULES VALUES (a) -- literals removed +EXPLAIN PAUSE JOBS FOR SCHEDULES VALUES (_) -- identifiers removed + +parse +PAUSE SCHEDULE a +---- +PAUSE SCHEDULES VALUES (a) -- normalized! +PAUSE SCHEDULES VALUES ((a)) -- fully parenthetized +PAUSE SCHEDULES VALUES (a) -- literals removed +PAUSE SCHEDULES VALUES (_) -- identifiers removed + +parse +EXPLAIN PAUSE SCHEDULE a +---- +EXPLAIN PAUSE SCHEDULES VALUES (a) -- normalized! +EXPLAIN PAUSE SCHEDULES VALUES ((a)) -- fully parenthetized +EXPLAIN PAUSE SCHEDULES VALUES (a) -- literals removed +EXPLAIN PAUSE SCHEDULES VALUES (_) -- identifiers removed + + + +parse +RESUME JOBS FOR SCHEDULES SELECT unnest(ARRAY[1, 2, 3]) +---- +RESUME JOBS FOR SCHEDULES SELECT unnest(ARRAY[1, 2, 3]) +RESUME JOBS FOR SCHEDULES SELECT ((unnest)((ARRAY[(1), (2), (3)]))) -- fully parenthetized +RESUME JOBS FOR SCHEDULES SELECT unnest(ARRAY[_, _, __more1__]) -- literals removed +RESUME JOBS FOR SCHEDULES SELECT unnest(ARRAY[1, 2, 3]) -- identifiers removed + +parse +EXPLAIN RESUME JOBS FOR SCHEDULES SELECT unnest(ARRAY[1, 2, 3]) +---- +EXPLAIN RESUME JOBS FOR SCHEDULES SELECT unnest(ARRAY[1, 2, 3]) +EXPLAIN RESUME JOBS FOR SCHEDULES SELECT ((unnest)((ARRAY[(1), (2), (3)]))) -- fully parenthetized +EXPLAIN RESUME JOBS FOR SCHEDULES SELECT unnest(ARRAY[_, _, __more1__]) -- literals removed +EXPLAIN RESUME JOBS FOR SCHEDULES SELECT unnest(ARRAY[1, 2, 3]) -- identifiers removed + +parse +RESUME JOB a +---- +RESUME JOBS VALUES (a) -- normalized! +RESUME JOBS VALUES ((a)) -- fully parenthetized +RESUME JOBS VALUES (a) -- literals removed +RESUME JOBS VALUES (_) -- identifiers removed + +parse +EXPLAIN RESUME JOB a +---- +EXPLAIN RESUME JOBS VALUES (a) -- normalized! +EXPLAIN RESUME JOBS VALUES ((a)) -- fully parenthetized +EXPLAIN RESUME JOBS VALUES (a) -- literals removed +EXPLAIN RESUME JOBS VALUES (_) -- identifiers removed + +parse +RESUME JOBS FOR SCHEDULE a +---- +RESUME JOBS FOR SCHEDULES VALUES (a) -- normalized! +RESUME JOBS FOR SCHEDULES VALUES ((a)) -- fully parenthetized +RESUME JOBS FOR SCHEDULES VALUES (a) -- literals removed +RESUME JOBS FOR SCHEDULES VALUES (_) -- identifiers removed + +parse +EXPLAIN RESUME JOBS FOR SCHEDULE a +---- +EXPLAIN RESUME JOBS FOR SCHEDULES VALUES (a) -- normalized! +EXPLAIN RESUME JOBS FOR SCHEDULES VALUES ((a)) -- fully parenthetized +EXPLAIN RESUME JOBS FOR SCHEDULES VALUES (a) -- literals removed +EXPLAIN RESUME JOBS FOR SCHEDULES VALUES (_) -- identifiers removed + + +parse +CANCEL JOBS FOR SCHEDULES (SELECT schedule_id FROM somewhere WHERE something = true) +---- +CANCEL JOBS FOR SCHEDULES (SELECT schedule_id FROM somewhere WHERE something = true) +CANCEL JOBS FOR SCHEDULES (SELECT (schedule_id) FROM somewhere WHERE ((something) = (true))) -- fully parenthetized +CANCEL JOBS FOR SCHEDULES (SELECT schedule_id FROM somewhere WHERE something = _) -- literals removed +CANCEL JOBS FOR SCHEDULES (SELECT _ FROM _ WHERE _ = true) -- identifiers removed + +parse +EXPLAIN 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) +EXPLAIN CANCEL JOBS FOR SCHEDULES (SELECT (schedule_id) FROM somewhere WHERE ((something) = (true))) -- fully parenthetized +EXPLAIN CANCEL JOBS FOR SCHEDULES (SELECT schedule_id FROM somewhere WHERE something = _) -- literals removed +EXPLAIN CANCEL JOBS FOR SCHEDULES (SELECT _ FROM _ WHERE _ = true) -- identifiers removed + +parse +CANCEL JOB a +---- +CANCEL JOBS VALUES (a) -- normalized! +CANCEL JOBS VALUES ((a)) -- fully parenthetized +CANCEL JOBS VALUES (a) -- literals removed +CANCEL JOBS VALUES (_) -- identifiers removed + +parse +EXPLAIN CANCEL JOB a +---- +EXPLAIN CANCEL JOBS VALUES (a) -- normalized! +EXPLAIN CANCEL JOBS VALUES ((a)) -- fully parenthetized +EXPLAIN CANCEL JOBS VALUES (a) -- literals removed +EXPLAIN CANCEL JOBS VALUES (_) -- identifiers removed + +parse +CANCEL JOBS FOR SCHEDULE a +---- +CANCEL JOBS FOR SCHEDULES VALUES (a) -- normalized! +CANCEL JOBS FOR SCHEDULES VALUES ((a)) -- fully parenthetized +CANCEL JOBS FOR SCHEDULES VALUES (a) -- literals removed +CANCEL JOBS FOR SCHEDULES VALUES (_) -- identifiers removed + +parse +EXPLAIN CANCEL JOBS FOR SCHEDULE a +---- +EXPLAIN CANCEL JOBS FOR SCHEDULES VALUES (a) -- normalized! +EXPLAIN CANCEL JOBS FOR SCHEDULES VALUES ((a)) -- fully parenthetized +EXPLAIN CANCEL JOBS FOR SCHEDULES VALUES (a) -- literals removed +EXPLAIN CANCEL JOBS FOR SCHEDULES VALUES (_) -- identifiers removed + +parse +SHOW JOBS FOR SCHEDULE a +---- +SHOW JOBS FOR SCHEDULES VALUES (a) -- normalized! +SHOW JOBS FOR SCHEDULES VALUES ((a)) -- fully parenthetized +SHOW JOBS FOR SCHEDULES VALUES (a) -- literals removed +SHOW JOBS FOR SCHEDULES VALUES (_) -- identifiers removed + +parse +EXPLAIN SHOW JOBS FOR SCHEDULE a +---- +EXPLAIN SHOW JOBS FOR SCHEDULES VALUES (a) -- normalized! +EXPLAIN SHOW JOBS FOR SCHEDULES VALUES ((a)) -- fully parenthetized +EXPLAIN SHOW JOBS FOR SCHEDULES VALUES (a) -- literals removed +EXPLAIN SHOW JOBS FOR SCHEDULES VALUES (_) -- identifiers removed + + +parse +SHOW JOBS FOR SCHEDULES SELECT 123 +---- +SHOW JOBS FOR SCHEDULES SELECT 123 +SHOW JOBS FOR SCHEDULES SELECT (123) -- fully parenthetized +SHOW JOBS FOR SCHEDULES SELECT _ -- literals removed +SHOW JOBS FOR SCHEDULES SELECT 123 -- identifiers removed + +parse +EXPLAIN SHOW JOBS FOR SCHEDULES SELECT 123 +---- +EXPLAIN SHOW JOBS FOR SCHEDULES SELECT 123 +EXPLAIN SHOW JOBS FOR SCHEDULES SELECT (123) -- fully parenthetized +EXPLAIN SHOW JOBS FOR SCHEDULES SELECT _ -- literals removed +EXPLAIN SHOW JOBS FOR SCHEDULES SELECT 123 -- identifiers removed + +parse +SHOW SCHEDULE 123 +---- +SHOW SCHEDULE 123 +SHOW SCHEDULE (123) -- fully parenthetized +SHOW SCHEDULE _ -- literals removed +SHOW SCHEDULE 123 -- identifiers removed + +parse +EXPLAIN SHOW SCHEDULE 123 +---- +EXPLAIN SHOW SCHEDULE 123 +EXPLAIN SHOW SCHEDULE (123) -- fully parenthetized +EXPLAIN SHOW SCHEDULE _ -- literals removed +EXPLAIN SHOW SCHEDULE 123 -- identifiers removed + +parse +SHOW SCHEDULES +---- +SHOW SCHEDULES +SHOW SCHEDULES -- fully parenthetized +SHOW SCHEDULES -- literals removed +SHOW SCHEDULES -- identifiers removed + +parse +EXPLAIN SHOW SCHEDULES +---- +EXPLAIN SHOW SCHEDULES +EXPLAIN SHOW SCHEDULES -- fully parenthetized +EXPLAIN SHOW SCHEDULES -- literals removed +EXPLAIN SHOW SCHEDULES -- identifiers removed + +parse +SHOW SCHEDULES FOR BACKUP +---- +SHOW SCHEDULES FOR BACKUP +SHOW SCHEDULES FOR BACKUP -- fully parenthetized +SHOW SCHEDULES FOR BACKUP -- literals removed +SHOW SCHEDULES FOR BACKUP -- identifiers removed + +parse +EXPLAIN SHOW SCHEDULES FOR BACKUP +---- +EXPLAIN SHOW SCHEDULES FOR BACKUP +EXPLAIN SHOW SCHEDULES FOR BACKUP -- fully parenthetized +EXPLAIN SHOW SCHEDULES FOR BACKUP -- literals removed +EXPLAIN SHOW SCHEDULES FOR BACKUP -- identifiers removed + +parse +SHOW PAUSED SCHEDULES +---- +SHOW PAUSED SCHEDULES +SHOW PAUSED SCHEDULES -- fully parenthetized +SHOW PAUSED SCHEDULES -- literals removed +SHOW PAUSED SCHEDULES -- identifiers removed + +parse +EXPLAIN SHOW PAUSED SCHEDULES +---- +EXPLAIN SHOW PAUSED SCHEDULES +EXPLAIN SHOW PAUSED SCHEDULES -- fully parenthetized +EXPLAIN SHOW PAUSED SCHEDULES -- literals removed +EXPLAIN SHOW PAUSED SCHEDULES -- identifiers removed + +parse +SHOW RUNNING SCHEDULES +---- +SHOW RUNNING SCHEDULES +SHOW RUNNING SCHEDULES -- fully parenthetized +SHOW RUNNING SCHEDULES -- literals removed +SHOW RUNNING SCHEDULES -- identifiers removed + +parse +EXPLAIN SHOW RUNNING SCHEDULES +---- +EXPLAIN SHOW RUNNING SCHEDULES +EXPLAIN SHOW RUNNING SCHEDULES -- fully parenthetized +EXPLAIN SHOW RUNNING SCHEDULES -- literals removed +EXPLAIN SHOW RUNNING SCHEDULES -- identifiers removed + +parse +SHOW PAUSED SCHEDULES FOR BACKUP +---- +SHOW PAUSED SCHEDULES FOR BACKUP +SHOW PAUSED SCHEDULES FOR BACKUP -- fully parenthetized +SHOW PAUSED SCHEDULES FOR BACKUP -- literals removed +SHOW PAUSED SCHEDULES FOR BACKUP -- identifiers removed + +parse +EXPLAIN SHOW PAUSED SCHEDULES FOR BACKUP +---- +EXPLAIN SHOW PAUSED SCHEDULES FOR BACKUP +EXPLAIN SHOW PAUSED SCHEDULES FOR BACKUP -- fully parenthetized +EXPLAIN SHOW PAUSED SCHEDULES FOR BACKUP -- literals removed +EXPLAIN SHOW PAUSED SCHEDULES FOR BACKUP -- identifiers removed + + + +parse +SHOW RUNNING SCHEDULES FOR BACKUP +---- +SHOW RUNNING SCHEDULES FOR BACKUP +SHOW RUNNING SCHEDULES FOR BACKUP -- fully parenthetized +SHOW RUNNING SCHEDULES FOR BACKUP -- literals removed +SHOW RUNNING SCHEDULES FOR BACKUP -- identifiers removed + +parse +EXPLAIN SHOW RUNNING SCHEDULES FOR BACKUP +---- +EXPLAIN SHOW RUNNING SCHEDULES FOR BACKUP +EXPLAIN SHOW RUNNING SCHEDULES FOR BACKUP -- fully parenthetized +EXPLAIN SHOW RUNNING SCHEDULES FOR BACKUP -- literals removed +EXPLAIN SHOW RUNNING SCHEDULES FOR BACKUP -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/copy b/pkg/sql/parser/testdata/parse/copy new file mode 100644 index 000000000000..2917dcb47d60 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/copy @@ -0,0 +1,85 @@ +parse +COPY t FROM STDIN +---- +COPY t FROM STDIN +COPY t FROM STDIN -- fully parenthetized +COPY t FROM STDIN -- literals removed +COPY _ FROM STDIN -- identifiers removed + +parse +COPY t (a, b, c) FROM STDIN +---- +COPY t (a, b, c) FROM STDIN +COPY t (a, b, c) FROM STDIN -- fully parenthetized +COPY t (a, b, c) FROM STDIN -- literals removed +COPY _ (_, _, _) FROM STDIN -- identifiers removed + +parse +COPY crdb_internal.file_upload FROM STDIN WITH destination = 'filename' +---- +COPY crdb_internal.file_upload FROM STDIN WITH destination = 'filename' +COPY crdb_internal.file_upload FROM STDIN WITH destination = ('filename') -- fully parenthetized +COPY crdb_internal.file_upload FROM STDIN WITH destination = _ -- literals removed +COPY crdb_internal.file_upload FROM STDIN WITH destination = '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +COPY _._ FROM STDIN WITH destination = 'filename' -- identifiers removed + +parse +COPY t (a, b, c) FROM STDIN WITH BINARY +---- +COPY t (a, b, c) FROM STDIN WITH BINARY +COPY t (a, b, c) FROM STDIN WITH BINARY -- fully parenthetized +COPY t (a, b, c) FROM STDIN WITH BINARY -- literals removed +COPY _ (_, _, _) FROM STDIN WITH BINARY -- identifiers removed + +parse +COPY crdb_internal.file_upload FROM STDIN WITH BINARY destination = 'filename' +---- +COPY crdb_internal.file_upload FROM STDIN WITH BINARY destination = 'filename' +COPY crdb_internal.file_upload FROM STDIN WITH BINARY destination = ('filename') -- fully parenthetized +COPY crdb_internal.file_upload FROM STDIN WITH BINARY destination = _ -- literals removed +COPY crdb_internal.file_upload FROM STDIN WITH BINARY destination = '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +COPY _._ FROM STDIN WITH BINARY destination = 'filename' -- identifiers removed + +parse +COPY t (a, b, c) FROM STDIN WITH CSV DELIMITER ',' NULL 'NUL' +---- +COPY t (a, b, c) FROM STDIN WITH CSV DELIMITER ',' NULL 'NUL' +COPY t (a, b, c) FROM STDIN WITH CSV DELIMITER (',') NULL ('NUL') -- fully parenthetized +COPY t (a, b, c) FROM STDIN WITH CSV DELIMITER _ NULL _ -- literals removed +COPY t (a, b, c) FROM STDIN WITH CSV DELIMITER '_' NULL '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +COPY _ (_, _, _) FROM STDIN WITH CSV DELIMITER ',' NULL 'NUL' -- identifiers removed + +parse +COPY t (a, b, c) FROM STDIN WITH CSV DELIMITER ',' destination = 'filename' +---- +COPY t (a, b, c) FROM STDIN WITH CSV DELIMITER ',' destination = 'filename' +COPY t (a, b, c) FROM STDIN WITH CSV DELIMITER (',') destination = ('filename') -- fully parenthetized +COPY t (a, b, c) FROM STDIN WITH CSV DELIMITER _ destination = _ -- literals removed +COPY t (a, b, c) FROM STDIN WITH CSV DELIMITER '_' destination = '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +COPY _ (_, _, _) FROM STDIN WITH CSV DELIMITER ',' destination = 'filename' -- identifiers removed + +parse +COPY t (a, b, c) FROM STDIN BINARY +---- +COPY t (a, b, c) FROM STDIN WITH BINARY -- normalized! +COPY t (a, b, c) FROM STDIN WITH BINARY -- fully parenthetized +COPY t (a, b, c) FROM STDIN WITH BINARY -- literals removed +COPY _ (_, _, _) FROM STDIN WITH BINARY -- identifiers removed + +parse +COPY t (a, b, c) FROM STDIN destination = 'filename' BINARY +---- +COPY t (a, b, c) FROM STDIN WITH BINARY destination = 'filename' -- normalized! +COPY t (a, b, c) FROM STDIN WITH BINARY destination = ('filename') -- fully parenthetized +COPY t (a, b, c) FROM STDIN WITH BINARY destination = _ -- literals removed +COPY t (a, b, c) FROM STDIN WITH BINARY destination = '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +COPY _ (_, _, _) FROM STDIN WITH BINARY destination = 'filename' -- identifiers removed + +parse +COPY t (a, b, c) FROM STDIN destination = 'filename' CSV DELIMITER ' ' +---- +COPY t (a, b, c) FROM STDIN WITH CSV DELIMITER ' ' destination = 'filename' -- normalized! +COPY t (a, b, c) FROM STDIN WITH CSV DELIMITER (' ') destination = ('filename') -- fully parenthetized +COPY t (a, b, c) FROM STDIN WITH CSV DELIMITER _ destination = _ -- literals removed +COPY t (a, b, c) FROM STDIN WITH CSV DELIMITER '_' destination = '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +COPY _ (_, _, _) FROM STDIN WITH CSV DELIMITER ' ' destination = 'filename' -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/create_database b/pkg/sql/parser/testdata/parse/create_database new file mode 100644 index 000000000000..cb34fe8f99dc --- /dev/null +++ b/pkg/sql/parser/testdata/parse/create_database @@ -0,0 +1,348 @@ +parse +CREATE DATABASE a +---- +CREATE DATABASE a +CREATE DATABASE a -- fully parenthetized +CREATE DATABASE a -- literals removed +CREATE DATABASE _ -- identifiers removed + +parse +EXPLAIN CREATE DATABASE a +---- +EXPLAIN CREATE DATABASE a +EXPLAIN CREATE DATABASE a -- fully parenthetized +EXPLAIN CREATE DATABASE a -- literals removed +EXPLAIN CREATE DATABASE _ -- identifiers removed + +# NB: the template is not currently edited out +# because we don't support the feature yet. + +parse +CREATE DATABASE a TEMPLATE = 'template0' +---- +CREATE DATABASE a TEMPLATE = 'template0' +CREATE DATABASE a TEMPLATE = 'template0' -- fully parenthetized +CREATE DATABASE a TEMPLATE = 'template0' -- literals removed +CREATE DATABASE _ TEMPLATE = 'template0' -- identifiers removed + +parse +CREATE DATABASE a TEMPLATE = 'invalid' +---- +CREATE DATABASE a TEMPLATE = 'invalid' +CREATE DATABASE a TEMPLATE = 'invalid' -- fully parenthetized +CREATE DATABASE a TEMPLATE = 'invalid' -- literals removed +CREATE DATABASE _ TEMPLATE = 'invalid' -- identifiers removed + +parse +CREATE DATABASE a TEMPLATE = template0 +---- +CREATE DATABASE a TEMPLATE = 'template0' -- normalized! +CREATE DATABASE a TEMPLATE = 'template0' -- fully parenthetized +CREATE DATABASE a TEMPLATE = 'template0' -- literals removed +CREATE DATABASE _ TEMPLATE = 'template0' -- identifiers removed + +parse +CREATE DATABASE a TEMPLATE = invalid +---- +CREATE DATABASE a TEMPLATE = 'invalid' -- normalized! +CREATE DATABASE a TEMPLATE = 'invalid' -- fully parenthetized +CREATE DATABASE a TEMPLATE = 'invalid' -- literals removed +CREATE DATABASE _ TEMPLATE = 'invalid' -- identifiers removed + +# NB: the encoding is not currently edited out +# because we don't support the feature yet. + +parse +CREATE DATABASE a ENCODING = 'UTF8' +---- +CREATE DATABASE a ENCODING = 'UTF8' +CREATE DATABASE a ENCODING = 'UTF8' -- fully parenthetized +CREATE DATABASE a ENCODING = 'UTF8' -- literals removed +CREATE DATABASE _ ENCODING = 'UTF8' -- identifiers removed + +parse +CREATE DATABASE a ENCODING = 'INVALID' +---- +CREATE DATABASE a ENCODING = 'INVALID' +CREATE DATABASE a ENCODING = 'INVALID' -- fully parenthetized +CREATE DATABASE a ENCODING = 'INVALID' -- literals removed +CREATE DATABASE _ ENCODING = 'INVALID' -- identifiers removed + +parse +CREATE DATABASE a WITH ENCODING = 'foo' +---- +CREATE DATABASE a ENCODING = 'foo' -- normalized! +CREATE DATABASE a ENCODING = 'foo' -- fully parenthetized +CREATE DATABASE a ENCODING = 'foo' -- literals removed +CREATE DATABASE _ ENCODING = 'foo' -- identifiers removed + + +# NB: the collation is not currently edited out +# because we don't support the feature yet. + +parse +CREATE DATABASE a LC_COLLATE = 'C.UTF-8' +---- +CREATE DATABASE a LC_COLLATE = 'C.UTF-8' +CREATE DATABASE a LC_COLLATE = 'C.UTF-8' -- fully parenthetized +CREATE DATABASE a LC_COLLATE = 'C.UTF-8' -- literals removed +CREATE DATABASE _ LC_COLLATE = 'C.UTF-8' -- identifiers removed + +parse +CREATE DATABASE a LC_COLLATE = 'INVALID' +---- +CREATE DATABASE a LC_COLLATE = 'INVALID' +CREATE DATABASE a LC_COLLATE = 'INVALID' -- fully parenthetized +CREATE DATABASE a LC_COLLATE = 'INVALID' -- literals removed +CREATE DATABASE _ LC_COLLATE = 'INVALID' -- identifiers removed + +# NB: the customization is not currently edited out +# because we don't support the feature yet. + +parse +CREATE DATABASE a LC_CTYPE = 'C.UTF-8' +---- +CREATE DATABASE a LC_CTYPE = 'C.UTF-8' +CREATE DATABASE a LC_CTYPE = 'C.UTF-8' -- fully parenthetized +CREATE DATABASE a LC_CTYPE = 'C.UTF-8' -- literals removed +CREATE DATABASE _ LC_CTYPE = 'C.UTF-8' -- identifiers removed + +parse +CREATE DATABASE a LC_CTYPE = 'INVALID' +---- +CREATE DATABASE a LC_CTYPE = 'INVALID' +CREATE DATABASE a LC_CTYPE = 'INVALID' -- fully parenthetized +CREATE DATABASE a LC_CTYPE = 'INVALID' -- literals removed +CREATE DATABASE _ LC_CTYPE = 'INVALID' -- identifiers removed + +parse +CREATE DATABASE a TEMPLATE = 'template0' ENCODING = 'UTF8' LC_COLLATE = 'C.UTF-8' LC_CTYPE = 'INVALID' +---- +CREATE DATABASE a TEMPLATE = 'template0' ENCODING = 'UTF8' LC_COLLATE = 'C.UTF-8' LC_CTYPE = 'INVALID' +CREATE DATABASE a TEMPLATE = 'template0' ENCODING = 'UTF8' LC_COLLATE = 'C.UTF-8' LC_CTYPE = 'INVALID' -- fully parenthetized +CREATE DATABASE a TEMPLATE = 'template0' ENCODING = 'UTF8' LC_COLLATE = 'C.UTF-8' LC_CTYPE = 'INVALID' -- literals removed +CREATE DATABASE _ TEMPLATE = 'template0' ENCODING = 'UTF8' LC_COLLATE = 'C.UTF-8' LC_CTYPE = 'INVALID' -- identifiers removed + +parse +CREATE DATABASE a CONNECTION LIMIT = 13 +---- +CREATE DATABASE a CONNECTION LIMIT = 13 +CREATE DATABASE a CONNECTION LIMIT = 13 -- fully parenthetized +CREATE DATABASE a CONNECTION LIMIT = _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE DATABASE _ CONNECTION LIMIT = 13 -- identifiers removed + +parse +CREATE DATABASE a WITH CONNECTION LIMIT = 13 +---- +CREATE DATABASE a CONNECTION LIMIT = 13 -- normalized! +CREATE DATABASE a CONNECTION LIMIT = 13 -- fully parenthetized +CREATE DATABASE a CONNECTION LIMIT = _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE DATABASE _ CONNECTION LIMIT = 13 -- identifiers removed + +parse +CREATE DATABASE a WITH CONNECTION LIMIT -1 +---- +CREATE DATABASE a -- normalized! +CREATE DATABASE a -- fully parenthetized +CREATE DATABASE a -- literals removed +CREATE DATABASE _ -- identifiers removed + +parse +CREATE DATABASE a REGIONS = "us-west-1", "us-west-2" +---- +CREATE DATABASE a REGIONS = "us-west-1", "us-west-2" +CREATE DATABASE a REGIONS = "us-west-1", "us-west-2" -- fully parenthetized +CREATE DATABASE a REGIONS = "us-west-1", "us-west-2" -- literals removed +CREATE DATABASE _ REGIONS = _, _ -- identifiers removed + +parse +CREATE DATABASE a SURVIVE REGION FAILURE +---- +CREATE DATABASE a SURVIVE REGION FAILURE +CREATE DATABASE a SURVIVE REGION FAILURE -- fully parenthetized +CREATE DATABASE a SURVIVE REGION FAILURE -- literals removed +CREATE DATABASE _ SURVIVE REGION FAILURE -- identifiers removed + +parse +CREATE DATABASE a SURVIVE ZONE FAILURE +---- +CREATE DATABASE a SURVIVE ZONE FAILURE +CREATE DATABASE a SURVIVE ZONE FAILURE -- fully parenthetized +CREATE DATABASE a SURVIVE ZONE FAILURE -- literals removed +CREATE DATABASE _ SURVIVE ZONE FAILURE -- identifiers removed + + +parse +CREATE DATABASE a PRIMARY REGION "us-west-1" +---- +CREATE DATABASE a PRIMARY REGION "us-west-1" +CREATE DATABASE a PRIMARY REGION "us-west-1" -- fully parenthetized +CREATE DATABASE a PRIMARY REGION "us-west-1" -- literals removed +CREATE DATABASE _ PRIMARY REGION _ -- identifiers removed + + +parse +CREATE DATABASE a PRIMARY REGION = "us-west-1" +---- +CREATE DATABASE a PRIMARY REGION "us-west-1" -- normalized! +CREATE DATABASE a PRIMARY REGION "us-west-1" -- fully parenthetized +CREATE DATABASE a PRIMARY REGION "us-west-1" -- literals removed +CREATE DATABASE _ PRIMARY REGION _ -- identifiers removed + +parse +ALTER DATABASE a SET PRIMARY REGION "us-west-1" +---- +ALTER DATABASE a PRIMARY REGION "us-west-1" -- normalized! +ALTER DATABASE a PRIMARY REGION "us-west-1" -- fully parenthetized +ALTER DATABASE a PRIMARY REGION "us-west-1" -- literals removed +ALTER DATABASE _ PRIMARY REGION _ -- identifiers removed + + +parse +CREATE DATABASE IF NOT EXISTS a +---- +CREATE DATABASE IF NOT EXISTS a +CREATE DATABASE IF NOT EXISTS a -- fully parenthetized +CREATE DATABASE IF NOT EXISTS a -- literals removed +CREATE DATABASE IF NOT EXISTS _ -- identifiers removed + +parse +CREATE DATABASE IF NOT EXISTS a TEMPLATE = 'template0' +---- +CREATE DATABASE IF NOT EXISTS a TEMPLATE = 'template0' +CREATE DATABASE IF NOT EXISTS a TEMPLATE = 'template0' -- fully parenthetized +CREATE DATABASE IF NOT EXISTS a TEMPLATE = 'template0' -- literals removed +CREATE DATABASE IF NOT EXISTS _ TEMPLATE = 'template0' -- identifiers removed + +parse +CREATE DATABASE IF NOT EXISTS a TEMPLATE = 'invalid' +---- +CREATE DATABASE IF NOT EXISTS a TEMPLATE = 'invalid' +CREATE DATABASE IF NOT EXISTS a TEMPLATE = 'invalid' -- fully parenthetized +CREATE DATABASE IF NOT EXISTS a TEMPLATE = 'invalid' -- literals removed +CREATE DATABASE IF NOT EXISTS _ TEMPLATE = 'invalid' -- identifiers removed + +parse +CREATE DATABASE IF NOT EXISTS a ENCODING = 'UTF8' +---- +CREATE DATABASE IF NOT EXISTS a ENCODING = 'UTF8' +CREATE DATABASE IF NOT EXISTS a ENCODING = 'UTF8' -- fully parenthetized +CREATE DATABASE IF NOT EXISTS a ENCODING = 'UTF8' -- literals removed +CREATE DATABASE IF NOT EXISTS _ ENCODING = 'UTF8' -- identifiers removed + +parse +CREATE DATABASE IF NOT EXISTS a ENCODING = 'INVALID' +---- +CREATE DATABASE IF NOT EXISTS a ENCODING = 'INVALID' +CREATE DATABASE IF NOT EXISTS a ENCODING = 'INVALID' -- fully parenthetized +CREATE DATABASE IF NOT EXISTS a ENCODING = 'INVALID' -- literals removed +CREATE DATABASE IF NOT EXISTS _ ENCODING = 'INVALID' -- identifiers removed + +parse +CREATE DATABASE IF NOT EXISTS a LC_COLLATE = 'C.UTF-8' +---- +CREATE DATABASE IF NOT EXISTS a LC_COLLATE = 'C.UTF-8' +CREATE DATABASE IF NOT EXISTS a LC_COLLATE = 'C.UTF-8' -- fully parenthetized +CREATE DATABASE IF NOT EXISTS a LC_COLLATE = 'C.UTF-8' -- literals removed +CREATE DATABASE IF NOT EXISTS _ LC_COLLATE = 'C.UTF-8' -- identifiers removed + +parse +CREATE DATABASE IF NOT EXISTS a LC_COLLATE = 'INVALID' +---- +CREATE DATABASE IF NOT EXISTS a LC_COLLATE = 'INVALID' +CREATE DATABASE IF NOT EXISTS a LC_COLLATE = 'INVALID' -- fully parenthetized +CREATE DATABASE IF NOT EXISTS a LC_COLLATE = 'INVALID' -- literals removed +CREATE DATABASE IF NOT EXISTS _ LC_COLLATE = 'INVALID' -- identifiers removed + +parse +CREATE DATABASE IF NOT EXISTS a LC_CTYPE = 'C.UTF-8' +---- +CREATE DATABASE IF NOT EXISTS a LC_CTYPE = 'C.UTF-8' +CREATE DATABASE IF NOT EXISTS a LC_CTYPE = 'C.UTF-8' -- fully parenthetized +CREATE DATABASE IF NOT EXISTS a LC_CTYPE = 'C.UTF-8' -- literals removed +CREATE DATABASE IF NOT EXISTS _ LC_CTYPE = 'C.UTF-8' -- identifiers removed + +parse +CREATE DATABASE IF NOT EXISTS a LC_CTYPE = 'INVALID' +---- +CREATE DATABASE IF NOT EXISTS a LC_CTYPE = 'INVALID' +CREATE DATABASE IF NOT EXISTS a LC_CTYPE = 'INVALID' -- fully parenthetized +CREATE DATABASE IF NOT EXISTS a LC_CTYPE = 'INVALID' -- literals removed +CREATE DATABASE IF NOT EXISTS _ LC_CTYPE = 'INVALID' -- identifiers removed + +parse +CREATE DATABASE IF NOT EXISTS a TEMPLATE = 'template0' ENCODING = 'UTF8' LC_COLLATE = 'C.UTF-8' 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 TEMPLATE = 'template0' ENCODING = 'UTF8' LC_COLLATE = 'C.UTF-8' LC_CTYPE = 'INVALID' -- fully parenthetized +CREATE DATABASE IF NOT EXISTS a TEMPLATE = 'template0' ENCODING = 'UTF8' LC_COLLATE = 'C.UTF-8' LC_CTYPE = 'INVALID' -- literals removed +CREATE DATABASE IF NOT EXISTS _ TEMPLATE = 'template0' ENCODING = 'UTF8' LC_COLLATE = 'C.UTF-8' LC_CTYPE = 'INVALID' -- identifiers removed + + +parse +CREATE DATABASE a REGION "us-west-1" +---- +CREATE DATABASE a REGIONS = "us-west-1" -- normalized! +CREATE DATABASE a REGIONS = "us-west-1" -- fully parenthetized +CREATE DATABASE a REGIONS = "us-west-1" -- literals removed +CREATE DATABASE _ REGIONS = _ -- identifiers removed + +parse +CREATE DATABASE IF NOT EXISTS a REGIONS = "us-west-1", "us-west-2" +---- +CREATE DATABASE IF NOT EXISTS a REGIONS = "us-west-1", "us-west-2" +CREATE DATABASE IF NOT EXISTS a REGIONS = "us-west-1", "us-west-2" -- fully parenthetized +CREATE DATABASE IF NOT EXISTS a REGIONS = "us-west-1", "us-west-2" -- literals removed +CREATE DATABASE IF NOT EXISTS _ REGIONS = _, _ -- identifiers removed + +parse +CREATE DATABASE IF NOT EXISTS a SURVIVE REGION FAILURE +---- +CREATE DATABASE IF NOT EXISTS a SURVIVE REGION FAILURE +CREATE DATABASE IF NOT EXISTS a SURVIVE REGION FAILURE -- fully parenthetized +CREATE DATABASE IF NOT EXISTS a SURVIVE REGION FAILURE -- literals removed +CREATE DATABASE IF NOT EXISTS _ SURVIVE REGION FAILURE -- identifiers removed + +parse +CREATE DATABASE IF NOT EXISTS a SURVIVE = REGION FAILURE +---- +CREATE DATABASE IF NOT EXISTS a SURVIVE REGION FAILURE -- normalized! +CREATE DATABASE IF NOT EXISTS a SURVIVE REGION FAILURE -- fully parenthetized +CREATE DATABASE IF NOT EXISTS a SURVIVE REGION FAILURE -- literals removed +CREATE DATABASE IF NOT EXISTS _ SURVIVE REGION FAILURE -- identifiers removed + + +parse +CREATE DATABASE IF NOT EXISTS a SURVIVE ZONE FAILURE +---- +CREATE DATABASE IF NOT EXISTS a SURVIVE ZONE FAILURE +CREATE DATABASE IF NOT EXISTS a SURVIVE ZONE FAILURE -- fully parenthetized +CREATE DATABASE IF NOT EXISTS a SURVIVE ZONE FAILURE -- literals removed +CREATE DATABASE IF NOT EXISTS _ SURVIVE ZONE FAILURE -- identifiers removed + +parse +CREATE DATABASE IF NOT EXISTS a SURVIVE = ZONE FAILURE +---- +CREATE DATABASE IF NOT EXISTS a SURVIVE ZONE FAILURE -- normalized! +CREATE DATABASE IF NOT EXISTS a SURVIVE ZONE FAILURE -- fully parenthetized +CREATE DATABASE IF NOT EXISTS a SURVIVE ZONE FAILURE -- literals removed +CREATE DATABASE IF NOT EXISTS _ SURVIVE ZONE FAILURE -- identifiers removed + +parse +CREATE DATABASE IF NOT EXISTS a SURVIVE = AVAILABILITY ZONE FAILURE +---- +CREATE DATABASE IF NOT EXISTS a SURVIVE ZONE FAILURE -- normalized! +CREATE DATABASE IF NOT EXISTS a SURVIVE ZONE FAILURE -- fully parenthetized +CREATE DATABASE IF NOT EXISTS a SURVIVE ZONE FAILURE -- literals removed +CREATE DATABASE IF NOT EXISTS _ SURVIVE ZONE FAILURE -- identifiers removed + + +parse +CREATE DATABASE IF NOT EXISTS a PRIMARY REGION "us-west-1" +---- +CREATE DATABASE IF NOT EXISTS a PRIMARY REGION "us-west-1" +CREATE DATABASE IF NOT EXISTS a PRIMARY REGION "us-west-1" -- fully parenthetized +CREATE DATABASE IF NOT EXISTS a PRIMARY REGION "us-west-1" -- literals removed +CREATE DATABASE IF NOT EXISTS _ PRIMARY REGION _ -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/create_index b/pkg/sql/parser/testdata/parse/create_index new file mode 100644 index 000000000000..6790e0acf348 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/create_index @@ -0,0 +1,412 @@ +parse +CREATE INDEX a ON b (c) +---- +CREATE INDEX a ON b (c) +CREATE INDEX a ON b (c) -- fully parenthetized +CREATE INDEX a ON b (c) -- literals removed +CREATE INDEX _ ON _ (_) -- identifiers removed + +parse +CREATE INDEX CONCURRENTLY a ON b (c) +---- +CREATE INDEX CONCURRENTLY a ON b (c) +CREATE INDEX CONCURRENTLY a ON b (c) -- fully parenthetized +CREATE INDEX CONCURRENTLY a ON b (c) -- literals removed +CREATE INDEX CONCURRENTLY _ ON _ (_) -- identifiers removed + +parse +EXPLAIN CREATE INDEX a ON b (c) +---- +EXPLAIN CREATE INDEX a ON b (c) +EXPLAIN CREATE INDEX a ON b (c) -- fully parenthetized +EXPLAIN CREATE INDEX a ON b (c) -- literals removed +EXPLAIN CREATE INDEX _ ON _ (_) -- identifiers removed + +parse +CREATE INDEX a ON b.c (d) +---- +CREATE INDEX a ON b.c (d) +CREATE INDEX a ON b.c (d) -- fully parenthetized +CREATE INDEX a ON b.c (d) -- literals removed +CREATE INDEX _ ON _._ (_) -- identifiers removed + +parse +CREATE INDEX ON a (b) +---- +CREATE INDEX ON a (b) +CREATE INDEX ON a (b) -- fully parenthetized +CREATE INDEX ON a (b) -- literals removed +CREATE INDEX ON _ (_) -- identifiers removed + +parse +CREATE INDEX ON a (b) STORING (c) +---- +CREATE INDEX ON a (b) STORING (c) +CREATE INDEX ON a (b) STORING (c) -- fully parenthetized +CREATE INDEX ON a (b) STORING (c) -- literals removed +CREATE INDEX ON _ (_) STORING (_) -- identifiers removed + + +parse +CREATE INDEX ON a (b) COVERING (c) +---- +CREATE INDEX ON a (b) STORING (c) -- normalized! +CREATE INDEX ON a (b) STORING (c) -- fully parenthetized +CREATE INDEX ON a (b) STORING (c) -- literals removed +CREATE INDEX ON _ (_) STORING (_) -- identifiers removed + +parse +CREATE INDEX ON a (b) INCLUDE (c) +---- +CREATE INDEX ON a (b) STORING (c) -- normalized! +CREATE INDEX ON a (b) STORING (c) -- fully parenthetized +CREATE INDEX ON a (b) STORING (c) -- literals removed +CREATE INDEX ON _ (_) STORING (_) -- identifiers removed + +parse +CREATE INDEX ON a (b) WHERE c > 3 +---- +CREATE INDEX ON a (b) WHERE c > 3 +CREATE INDEX ON a (b) WHERE ((c) > (3)) -- fully parenthetized +CREATE INDEX ON a (b) WHERE c > _ -- literals removed +CREATE INDEX ON _ (_) WHERE _ > 3 -- identifiers removed + +parse +CREATE INDEX ON a (b) INTERLEAVE IN PARENT c (d) +---- +CREATE INDEX ON a (b) INTERLEAVE IN PARENT c (d) +CREATE INDEX ON a (b) INTERLEAVE IN PARENT c (d) -- fully parenthetized +CREATE INDEX ON a (b) INTERLEAVE IN PARENT c (d) -- literals removed +CREATE INDEX ON _ (_) INTERLEAVE IN PARENT _ (_) -- identifiers removed + +parse +CREATE INDEX ON a (b) INTERLEAVE IN PARENT c.d (e) +---- +CREATE INDEX ON a (b) INTERLEAVE IN PARENT c.d (e) +CREATE INDEX ON a (b) INTERLEAVE IN PARENT c.d (e) -- fully parenthetized +CREATE INDEX ON a (b) INTERLEAVE IN PARENT c.d (e) -- literals removed +CREATE INDEX ON _ (_) INTERLEAVE IN PARENT _._ (_) -- identifiers removed + +parse +CREATE INDEX ON a (b ASC, c DESC) +---- +CREATE INDEX ON a (b ASC, c DESC) +CREATE INDEX ON a (b ASC, c DESC) -- fully parenthetized +CREATE INDEX ON a (b ASC, c DESC) -- literals removed +CREATE INDEX ON _ (_ ASC, _ DESC) -- identifiers removed + +parse +CREATE INDEX ON a (b NULLS FIRST, c ASC NULLS FIRST, d DESC NULLS LAST) +---- +CREATE INDEX ON a (b NULLS FIRST, c ASC NULLS FIRST, d DESC NULLS LAST) +CREATE INDEX ON a (b NULLS FIRST, c ASC NULLS FIRST, d DESC NULLS LAST) -- fully parenthetized +CREATE INDEX ON a (b NULLS FIRST, c ASC NULLS FIRST, d DESC NULLS LAST) -- literals removed +CREATE INDEX ON _ (_ NULLS FIRST, _ ASC NULLS FIRST, _ DESC NULLS LAST) -- identifiers removed + +parse +CREATE INDEX IF NOT EXISTS i ON a (b) WHERE c > 3 +---- +CREATE INDEX IF NOT EXISTS i ON a (b) WHERE c > 3 +CREATE INDEX IF NOT EXISTS i ON a (b) WHERE ((c) > (3)) -- fully parenthetized +CREATE INDEX IF NOT EXISTS i ON a (b) WHERE c > _ -- literals removed +CREATE INDEX IF NOT EXISTS _ ON _ (_) WHERE _ > 3 -- identifiers removed + +parse +CREATE UNIQUE INDEX a ON b (c) +---- +CREATE UNIQUE INDEX a ON b (c) +CREATE UNIQUE INDEX a ON b (c) -- fully parenthetized +CREATE UNIQUE INDEX a ON b (c) -- literals removed +CREATE UNIQUE INDEX _ ON _ (_) -- identifiers removed + +parse +CREATE UNIQUE INDEX a ON b (c) STORING (d) +---- +CREATE UNIQUE INDEX a ON b (c) STORING (d) +CREATE UNIQUE INDEX a ON b (c) STORING (d) -- fully parenthetized +CREATE UNIQUE INDEX a ON b (c) STORING (d) -- literals removed +CREATE UNIQUE INDEX _ ON _ (_) STORING (_) -- identifiers removed + +parse +CREATE UNIQUE INDEX a ON b (c) WHERE d > 3 +---- +CREATE UNIQUE INDEX a ON b (c) WHERE d > 3 +CREATE UNIQUE INDEX a ON b (c) WHERE ((d) > (3)) -- fully parenthetized +CREATE UNIQUE INDEX a ON b (c) WHERE d > _ -- literals removed +CREATE UNIQUE INDEX _ ON _ (_) WHERE _ > 3 -- identifiers removed + +parse +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) +CREATE UNIQUE INDEX a ON b (c) INTERLEAVE IN PARENT d (e, f) -- fully parenthetized +CREATE UNIQUE INDEX a ON b (c) INTERLEAVE IN PARENT d (e, f) -- literals removed +CREATE UNIQUE INDEX _ ON _ (_) INTERLEAVE IN PARENT _ (_, _) -- identifiers removed + +parse +CREATE UNIQUE INDEX a ON b (c) INTERLEAVE IN PARENT d.e (f, g) +---- +CREATE UNIQUE INDEX a ON b (c) INTERLEAVE IN PARENT d.e (f, g) +CREATE UNIQUE INDEX a ON b (c) INTERLEAVE IN PARENT d.e (f, g) -- fully parenthetized +CREATE UNIQUE INDEX a ON b (c) INTERLEAVE IN PARENT d.e (f, g) -- literals removed +CREATE UNIQUE INDEX _ ON _ (_) INTERLEAVE IN PARENT _._ (_, _) -- identifiers removed + +parse +CREATE UNIQUE INDEX a ON b.c (d) +---- +CREATE UNIQUE INDEX a ON b.c (d) +CREATE UNIQUE INDEX a ON b.c (d) -- fully parenthetized +CREATE UNIQUE INDEX a ON b.c (d) -- literals removed +CREATE UNIQUE INDEX _ ON _._ (_) -- identifiers removed + +parse +CREATE INVERTED INDEX a ON b (c) +---- +CREATE INVERTED INDEX a ON b (c) +CREATE INVERTED INDEX a ON b (c) -- fully parenthetized +CREATE INVERTED INDEX a ON b (c) -- literals removed +CREATE INVERTED INDEX _ ON _ (_) -- identifiers removed + +parse +CREATE INVERTED INDEX a ON b.c (d) +---- +CREATE INVERTED INDEX a ON b.c (d) +CREATE INVERTED INDEX a ON b.c (d) -- fully parenthetized +CREATE INVERTED INDEX a ON b.c (d) -- literals removed +CREATE INVERTED INDEX _ ON _._ (_) -- identifiers removed + +parse +CREATE INVERTED INDEX a ON b (c) STORING (d) +---- +CREATE INVERTED INDEX a ON b (c) STORING (d) +CREATE INVERTED INDEX a ON b (c) STORING (d) -- fully parenthetized +CREATE INVERTED INDEX a ON b (c) STORING (d) -- literals removed +CREATE INVERTED INDEX _ ON _ (_) STORING (_) -- identifiers removed + + +parse +CREATE INVERTED INDEX a ON b (c) WHERE d > 3 +---- +CREATE INVERTED INDEX a ON b (c) WHERE d > 3 +CREATE INVERTED INDEX a ON b (c) WHERE ((d) > (3)) -- fully parenthetized +CREATE INVERTED INDEX a ON b (c) WHERE d > _ -- literals removed +CREATE INVERTED INDEX _ ON _ (_) WHERE _ > 3 -- identifiers removed + +parse +CREATE INVERTED INDEX a ON b (c) INTERLEAVE IN PARENT d (e) +---- +CREATE INVERTED INDEX a ON b (c) INTERLEAVE IN PARENT d (e) +CREATE INVERTED INDEX a ON b (c) INTERLEAVE IN PARENT d (e) -- fully parenthetized +CREATE INVERTED INDEX a ON b (c) INTERLEAVE IN PARENT d (e) -- literals removed +CREATE INVERTED INDEX _ ON _ (_) INTERLEAVE IN PARENT _ (_) -- identifiers removed + +parse +CREATE INVERTED INDEX IF NOT EXISTS a ON b (c) WHERE d > 3 +---- +CREATE INVERTED INDEX IF NOT EXISTS a ON b (c) WHERE d > 3 +CREATE INVERTED INDEX IF NOT EXISTS a ON b (c) WHERE ((d) > (3)) -- fully parenthetized +CREATE INVERTED INDEX IF NOT EXISTS a ON b (c) WHERE d > _ -- literals removed +CREATE INVERTED INDEX IF NOT EXISTS _ ON _ (_) WHERE _ > 3 -- identifiers removed + +parse +CREATE INDEX a ON b USING GIN (c) +---- +CREATE INVERTED INDEX a ON b (c) -- normalized! +CREATE INVERTED INDEX a ON b (c) -- fully parenthetized +CREATE INVERTED INDEX a ON b (c) -- literals removed +CREATE INVERTED INDEX _ ON _ (_) -- identifiers removed + +parse +CREATE INDEX a ON b USING GIST (c) +---- +CREATE INVERTED INDEX a ON b (c) -- normalized! +CREATE INVERTED INDEX a ON b (c) -- fully parenthetized +CREATE INVERTED INDEX a ON b (c) -- literals removed +CREATE INVERTED INDEX _ ON _ (_) -- identifiers removed + +parse +CREATE UNIQUE INDEX a ON b USING GIN (c) +---- +CREATE UNIQUE INVERTED INDEX a ON b (c) -- normalized! +CREATE UNIQUE INVERTED INDEX a ON b (c) -- fully parenthetized +CREATE UNIQUE INVERTED INDEX a ON b (c) -- literals removed +CREATE UNIQUE INVERTED INDEX _ ON _ (_) -- identifiers removed + +# TODO(knz): Arguably the storage parameters under WITH should probably +# not removed under FmtAnonymize? + +parse +CREATE INDEX a ON b (c) WITH (fillfactor = 100, y_bounds = 50) +---- +CREATE INDEX a ON b (c) WITH (fillfactor = 100, y_bounds = 50) +CREATE INDEX a ON b (c) WITH (fillfactor = (100), y_bounds = (50)) -- fully parenthetized +CREATE INDEX a ON b (c) WITH (fillfactor = _, y_bounds = _) -- literals removed +CREATE INDEX _ ON _ (_) WITH (_ = 100, _ = 50) -- identifiers removed + +parse +CREATE INDEX ON a ((a + b)) +---- +CREATE INDEX ON a ((a + b)) +CREATE INDEX ON a ((((a) + (b)))) -- fully parenthetized +CREATE INDEX ON a ((a + b)) -- literals removed +CREATE INDEX ON _ ((_ + _)) -- identifiers removed + +parse +CREATE INDEX ON a (lower(a)) +---- +CREATE INDEX ON a (lower(a)) +CREATE INDEX ON a (((lower)((a)))) -- fully parenthetized +CREATE INDEX ON a (lower(a)) -- literals removed +CREATE INDEX ON _ (lower(_)) -- identifiers removed + +parse +CREATE INDEX ON a (a, lower(b)) +---- +CREATE INDEX ON a (a, lower(b)) +CREATE INDEX ON a (a, ((lower)((b)))) -- fully parenthetized +CREATE INDEX ON a (a, lower(b)) -- literals removed +CREATE INDEX ON _ (_, lower(_)) -- identifiers removed + +parse +CREATE INDEX ON a (((lower(a) || ' ') || lower(b))) +---- +CREATE INDEX ON a (((lower(a) || ' ') || lower(b))) +CREATE INDEX ON a ((((((((lower)((a))) || (' ')))) || ((lower)((b)))))) -- fully parenthetized +CREATE INDEX ON a (((lower(a) || _) || lower(b))) -- literals removed +CREATE INDEX ON _ (((lower(_) || ' ') || lower(_))) -- identifiers removed + +parse +CREATE INDEX ON a (a, (a + 1), (b + 2)) +---- +CREATE INDEX ON a (a, (a + 1), (b + 2)) +CREATE INDEX ON a (a, (((a) + (1))), (((b) + (2)))) -- fully parenthetized +CREATE INDEX ON a (a, (a + _), (b + _)) -- literals removed +CREATE INDEX ON _ (_, (_ + 1), (_ + 2)) -- identifiers removed + +parse +CREATE INDEX ON a (lower(a)) +---- +CREATE INDEX ON a (lower(a)) +CREATE INDEX ON a (((lower)((a)))) -- fully parenthetized +CREATE INDEX ON a (lower(a)) -- literals removed +CREATE INDEX ON _ (lower(_)) -- identifiers removed + +parse +CREATE INDEX ON a (lower(a), lower(b)) +---- +CREATE INDEX ON a (lower(a), lower(b)) +CREATE INDEX ON a (((lower)((a))), ((lower)((b)))) -- fully parenthetized +CREATE INDEX ON a (lower(a), lower(b)) -- literals removed +CREATE INDEX ON _ (lower(_), lower(_)) -- identifiers removed + +parse +CREATE INDEX ON a (a, lower(b)) +---- +CREATE INDEX ON a (a, lower(b)) +CREATE INDEX ON a (a, ((lower)((b)))) -- fully parenthetized +CREATE INDEX ON a (a, lower(b)) -- literals removed +CREATE INDEX ON _ (_, lower(_)) -- identifiers removed + +parse +CREATE INDEX ON a (((lower(a) || ' ') || lower(b))) +---- +CREATE INDEX ON a (((lower(a) || ' ') || lower(b))) +CREATE INDEX ON a ((((((((lower)((a))) || (' ')))) || ((lower)((b)))))) -- fully parenthetized +CREATE INDEX ON a (((lower(a) || _) || lower(b))) -- literals removed +CREATE INDEX ON _ (((lower(_) || ' ') || lower(_))) -- identifiers removed + +parse +CREATE INDEX ON a (a, (lower(b))) +---- +CREATE INDEX ON a (a, lower(b)) -- normalized! +CREATE INDEX ON a (a, ((lower)((b)))) -- fully parenthetized +CREATE INDEX ON a (a, lower(b)) -- literals removed +CREATE INDEX ON _ (_, lower(_)) -- identifiers removed + +parse +CREATE INDEX ON a ((lower(a) || ' ' || lower(b))) +---- +CREATE INDEX ON a (((lower(a) || ' ') || lower(b))) -- normalized! +CREATE INDEX ON a (((((((lower)((a))) || (' '))) || ((lower)((b)))))) -- fully parenthetized +CREATE INDEX ON a (((lower(a) || _) || lower(b))) -- literals removed +CREATE INDEX ON _ (((lower(_) || ' ') || lower(_))) -- identifiers removed + +parse +CREATE UNIQUE INDEX ON a ((a + b)) +---- +CREATE UNIQUE INDEX ON a ((a + b)) +CREATE UNIQUE INDEX ON a ((((a) + (b)))) -- fully parenthetized +CREATE UNIQUE INDEX ON a ((a + b)) -- literals removed +CREATE UNIQUE INDEX ON _ ((_ + _)) -- identifiers removed + +parse +CREATE UNIQUE INDEX ON a (lower(a)) +---- +CREATE UNIQUE INDEX ON a (lower(a)) +CREATE UNIQUE INDEX ON a (((lower)((a)))) -- fully parenthetized +CREATE UNIQUE INDEX ON a (lower(a)) -- literals removed +CREATE UNIQUE INDEX ON _ (lower(_)) -- identifiers removed + +parse +CREATE UNIQUE INDEX ON a (a, lower(b)) +---- +CREATE UNIQUE INDEX ON a (a, lower(b)) +CREATE UNIQUE INDEX ON a (a, ((lower)((b)))) -- fully parenthetized +CREATE UNIQUE INDEX ON a (a, lower(b)) -- literals removed +CREATE UNIQUE INDEX ON _ (_, lower(_)) -- identifiers removed + +parse +CREATE UNIQUE INDEX ON a (((lower(a) || ' ') || lower(b))) +---- +CREATE UNIQUE INDEX ON a (((lower(a) || ' ') || lower(b))) +CREATE UNIQUE INDEX ON a ((((((((lower)((a))) || (' ')))) || ((lower)((b)))))) -- fully parenthetized +CREATE UNIQUE INDEX ON a (((lower(a) || _) || lower(b))) -- literals removed +CREATE UNIQUE INDEX ON _ (((lower(_) || ' ') || lower(_))) -- identifiers removed + +parse +CREATE UNIQUE INDEX ON a (a, (a + 1), (b + 2)) +---- +CREATE UNIQUE INDEX ON a (a, (a + 1), (b + 2)) +CREATE UNIQUE INDEX ON a (a, (((a) + (1))), (((b) + (2)))) -- fully parenthetized +CREATE UNIQUE INDEX ON a (a, (a + _), (b + _)) -- literals removed +CREATE UNIQUE INDEX ON _ (_, (_ + 1), (_ + 2)) -- identifiers removed + +parse +CREATE UNIQUE INDEX ON a (lower(a)) +---- +CREATE UNIQUE INDEX ON a (lower(a)) +CREATE UNIQUE INDEX ON a (((lower)((a)))) -- fully parenthetized +CREATE UNIQUE INDEX ON a (lower(a)) -- literals removed +CREATE UNIQUE INDEX ON _ (lower(_)) -- identifiers removed + +parse +CREATE UNIQUE INDEX ON a (lower(a), lower(b)) +---- +CREATE UNIQUE INDEX ON a (lower(a), lower(b)) +CREATE UNIQUE INDEX ON a (((lower)((a))), ((lower)((b)))) -- fully parenthetized +CREATE UNIQUE INDEX ON a (lower(a), lower(b)) -- literals removed +CREATE UNIQUE INDEX ON _ (lower(_), lower(_)) -- identifiers removed + +parse +CREATE UNIQUE INDEX ON a (a, lower(b)) +---- +CREATE UNIQUE INDEX ON a (a, lower(b)) +CREATE UNIQUE INDEX ON a (a, ((lower)((b)))) -- fully parenthetized +CREATE UNIQUE INDEX ON a (a, lower(b)) -- literals removed +CREATE UNIQUE INDEX ON _ (_, lower(_)) -- identifiers removed + +parse +CREATE UNIQUE INDEX ON a (((lower(a) || ' ') || lower(b))) +---- +CREATE UNIQUE INDEX ON a (((lower(a) || ' ') || lower(b))) +CREATE UNIQUE INDEX ON a ((((((((lower)((a))) || (' ')))) || ((lower)((b)))))) -- fully parenthetized +CREATE UNIQUE INDEX ON a (((lower(a) || _) || lower(b))) -- literals removed +CREATE UNIQUE INDEX ON _ (((lower(_) || ' ') || lower(_))) -- identifiers removed + +parse +CREATE INVERTED INDEX ON a ((ARRAY[a, b])) +---- +CREATE INVERTED INDEX ON a ((ARRAY[a, b])) +CREATE INVERTED INDEX ON a (((ARRAY[(a), (b)]))) -- fully parenthetized +CREATE INVERTED INDEX ON a ((ARRAY[a, b])) -- literals removed +CREATE INVERTED INDEX ON _ ((ARRAY[_, _])) -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/create_misc b/pkg/sql/parser/testdata/parse/create_misc new file mode 100644 index 000000000000..2c3fc978e194 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/create_misc @@ -0,0 +1,108 @@ +# NB: extension names do not get anonymized. +# Refer to (*CreateExtension).Format() for details. + +parse +CREATE EXTENSION bob +---- +CREATE EXTENSION bob +CREATE EXTENSION bob -- fully parenthetized +CREATE EXTENSION bob -- literals removed +CREATE EXTENSION bob -- identifiers removed + +parse +CREATE EXTENSION IF NOT EXISTS bob +---- +CREATE EXTENSION IF NOT EXISTS bob +CREATE EXTENSION IF NOT EXISTS bob -- fully parenthetized +CREATE EXTENSION IF NOT EXISTS bob -- literals removed +CREATE EXTENSION IF NOT EXISTS bob -- identifiers removed + +parse +CREATE STATISTICS a ON col1 FROM t +---- +CREATE STATISTICS a ON col1 FROM t +CREATE STATISTICS a ON col1 FROM t -- fully parenthetized +CREATE STATISTICS a ON col1 FROM t -- literals removed +CREATE STATISTICS _ ON _ FROM _ -- identifiers removed + +parse +EXPLAIN CREATE STATISTICS a ON col1 FROM t +---- +EXPLAIN CREATE STATISTICS a ON col1 FROM t +EXPLAIN CREATE STATISTICS a ON col1 FROM t -- fully parenthetized +EXPLAIN CREATE STATISTICS a ON col1 FROM t -- literals removed +EXPLAIN CREATE STATISTICS _ ON _ FROM _ -- identifiers removed + +parse +CREATE STATISTICS a FROM t +---- +CREATE STATISTICS a FROM t +CREATE STATISTICS a FROM t -- fully parenthetized +CREATE STATISTICS a FROM t -- literals removed +CREATE STATISTICS _ FROM _ -- identifiers removed + +parse +CREATE STATISTICS a FROM [53] +---- +CREATE STATISTICS a FROM [53] +CREATE STATISTICS a FROM [53] -- fully parenthetized +CREATE STATISTICS a FROM [53] -- literals removed +CREATE STATISTICS _ FROM [53] -- identifiers removed + +parse +CREATE STATISTICS a ON col1, col2 FROM t +---- +CREATE STATISTICS a ON col1, col2 FROM t +CREATE STATISTICS a ON col1, col2 FROM t -- fully parenthetized +CREATE STATISTICS a ON col1, col2 FROM t -- literals removed +CREATE STATISTICS _ ON _, _ FROM _ -- identifiers removed + +parse +CREATE STATISTICS a ON col1 FROM d.t +---- +CREATE STATISTICS a ON col1 FROM d.t +CREATE STATISTICS a ON col1 FROM d.t -- fully parenthetized +CREATE STATISTICS a ON col1 FROM d.t -- literals removed +CREATE STATISTICS _ ON _ FROM _._ -- identifiers removed + +parse +CREATE STATISTICS a ON col1 FROM t +---- +CREATE STATISTICS a ON col1 FROM t +CREATE STATISTICS a ON col1 FROM t -- fully parenthetized +CREATE STATISTICS a ON col1 FROM t -- literals removed +CREATE STATISTICS _ ON _ FROM _ -- identifiers removed + +parse +CREATE STATISTICS a ON col1 FROM t WITH OPTIONS THROTTLING 0.9 +---- +CREATE STATISTICS a ON col1 FROM t WITH OPTIONS THROTTLING 0.9 +CREATE STATISTICS a ON col1 FROM t WITH OPTIONS THROTTLING 0.9 -- fully parenthetized +CREATE STATISTICS a ON col1 FROM t WITH OPTIONS THROTTLING _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE STATISTICS _ ON _ FROM _ WITH OPTIONS THROTTLING 0.9 -- identifiers removed + +parse +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 AS OF SYSTEM TIME '2016-01-01' +CREATE STATISTICS a ON col1 FROM t WITH OPTIONS AS OF SYSTEM TIME ('2016-01-01') -- fully parenthetized +CREATE STATISTICS a ON col1 FROM t WITH OPTIONS AS OF SYSTEM TIME _ -- literals removed +CREATE STATISTICS _ ON _ FROM _ WITH OPTIONS AS OF SYSTEM TIME '2016-01-01' -- identifiers removed + +parse +CREATE STATISTICS a ON col1 FROM t WITH OPTIONS THROTTLING 0.1 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' +CREATE STATISTICS a ON col1 FROM t WITH OPTIONS THROTTLING 0.1 AS OF SYSTEM TIME ('2016-01-01') -- fully parenthetized +CREATE STATISTICS a ON col1 FROM t WITH OPTIONS THROTTLING _ AS OF SYSTEM TIME _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE STATISTICS _ ON _ FROM _ WITH OPTIONS THROTTLING 0.1 AS OF SYSTEM TIME '2016-01-01' -- identifiers removed + +parse +CREATE STATISTICS a ON col1 FROM t AS OF SYSTEM TIME '2016-01-01' +---- +CREATE STATISTICS a ON col1 FROM t WITH OPTIONS AS OF SYSTEM TIME '2016-01-01' -- normalized! +CREATE STATISTICS a ON col1 FROM t WITH OPTIONS AS OF SYSTEM TIME ('2016-01-01') -- fully parenthetized +CREATE STATISTICS a ON col1 FROM t WITH OPTIONS AS OF SYSTEM TIME _ -- literals removed +CREATE STATISTICS _ ON _ FROM _ WITH OPTIONS AS OF SYSTEM TIME '2016-01-01' -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/create_schedule b/pkg/sql/parser/testdata/parse/create_schedule new file mode 100644 index 000000000000..bbe8052ad526 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/create_schedule @@ -0,0 +1,62 @@ +parse +CREATE SCHEDULE FOR BACKUP TABLE foo INTO 'bar' RECURRING '@hourly' +---- +CREATE SCHEDULE FOR BACKUP TABLE foo INTO 'bar' RECURRING '@hourly' +CREATE SCHEDULE FOR BACKUP TABLE (foo) INTO ('bar') RECURRING ('@hourly') -- fully parenthetized +CREATE SCHEDULE FOR BACKUP TABLE foo INTO _ RECURRING _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE SCHEDULE FOR BACKUP TABLE _ INTO 'bar' RECURRING '@hourly' -- identifiers removed + +parse +CREATE SCHEDULE 'my schedule' FOR BACKUP TABLE foo INTO 'bar' RECURRING '@daily' +---- +CREATE SCHEDULE 'my schedule' FOR BACKUP TABLE foo INTO 'bar' RECURRING '@daily' +CREATE SCHEDULE ('my schedule') FOR BACKUP TABLE (foo) INTO ('bar') RECURRING ('@daily') -- fully parenthetized +CREATE SCHEDULE _ FOR BACKUP TABLE foo INTO _ RECURRING _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE SCHEDULE 'my schedule' FOR BACKUP TABLE _ INTO 'bar' RECURRING '@daily' -- identifiers removed + +parse +CREATE SCHEDULE FOR BACKUP TABLE foo INTO 'bar' RECURRING '@daily' +---- +CREATE SCHEDULE FOR BACKUP TABLE foo INTO 'bar' RECURRING '@daily' +CREATE SCHEDULE FOR BACKUP TABLE (foo) INTO ('bar') RECURRING ('@daily') -- fully parenthetized +CREATE SCHEDULE FOR BACKUP TABLE foo INTO _ RECURRING _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE SCHEDULE FOR BACKUP TABLE _ INTO 'bar' RECURRING '@daily' -- identifiers removed + +parse +CREATE SCHEDULE FOR BACKUP TABLE foo, bar, buz INTO 'bar' RECURRING '@daily' FULL BACKUP ALWAYS +---- +CREATE SCHEDULE FOR BACKUP TABLE foo, bar, buz INTO 'bar' RECURRING '@daily' FULL BACKUP ALWAYS +CREATE SCHEDULE FOR BACKUP TABLE (foo), (bar), (buz) INTO ('bar') RECURRING ('@daily') FULL BACKUP ALWAYS -- fully parenthetized +CREATE SCHEDULE FOR BACKUP TABLE foo, bar, buz INTO _ RECURRING _ FULL BACKUP ALWAYS -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE SCHEDULE FOR BACKUP TABLE _, _, _ INTO 'bar' RECURRING '@daily' FULL BACKUP ALWAYS -- identifiers removed + +parse +CREATE SCHEDULE FOR BACKUP TABLE foo, bar, buz INTO 'bar' RECURRING '@daily' FULL BACKUP '@weekly' +---- +CREATE SCHEDULE FOR BACKUP TABLE foo, bar, buz INTO 'bar' RECURRING '@daily' FULL BACKUP '@weekly' +CREATE SCHEDULE FOR BACKUP TABLE (foo), (bar), (buz) INTO ('bar') RECURRING ('@daily') FULL BACKUP ('@weekly') -- fully parenthetized +CREATE SCHEDULE FOR BACKUP TABLE foo, bar, buz INTO _ RECURRING _ FULL BACKUP _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE SCHEDULE FOR BACKUP TABLE _, _, _ INTO 'bar' RECURRING '@daily' FULL BACKUP '@weekly' -- identifiers removed + +parse +CREATE SCHEDULE FOR BACKUP TABLE foo, bar, buz INTO 'bar' WITH revision_history RECURRING '@daily' FULL BACKUP '@weekly' +---- +CREATE SCHEDULE FOR BACKUP TABLE foo, bar, buz INTO 'bar' WITH revision_history RECURRING '@daily' FULL BACKUP '@weekly' +CREATE SCHEDULE FOR BACKUP TABLE (foo), (bar), (buz) INTO ('bar') WITH revision_history RECURRING ('@daily') FULL BACKUP ('@weekly') -- fully parenthetized +CREATE SCHEDULE FOR BACKUP TABLE foo, bar, buz INTO _ WITH revision_history RECURRING _ FULL BACKUP _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE SCHEDULE FOR BACKUP TABLE _, _, _ INTO 'bar' WITH revision_history RECURRING '@daily' FULL BACKUP '@weekly' -- identifiers removed + +parse +CREATE SCHEDULE FOR BACKUP INTO 'bar' WITH revision_history RECURRING '@daily' FULL BACKUP '@weekly' WITH SCHEDULE OPTIONS foo = 'bar' +---- +CREATE SCHEDULE FOR BACKUP INTO 'bar' WITH revision_history RECURRING '@daily' FULL BACKUP '@weekly' WITH SCHEDULE OPTIONS foo = 'bar' +CREATE SCHEDULE FOR BACKUP INTO ('bar') WITH revision_history RECURRING ('@daily') FULL BACKUP ('@weekly') WITH SCHEDULE OPTIONS foo = ('bar') -- fully parenthetized +CREATE SCHEDULE FOR BACKUP INTO _ WITH revision_history RECURRING _ FULL BACKUP _ WITH SCHEDULE OPTIONS foo = _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE SCHEDULE FOR BACKUP INTO 'bar' WITH revision_history RECURRING '@daily' FULL BACKUP '@weekly' WITH SCHEDULE OPTIONS _ = 'bar' -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/create_schema b/pkg/sql/parser/testdata/parse/create_schema new file mode 100644 index 000000000000..5310a57fa0f4 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/create_schema @@ -0,0 +1,79 @@ +parse +CREATE SCHEMA IF NOT EXISTS foo +---- +CREATE SCHEMA IF NOT EXISTS foo +CREATE SCHEMA IF NOT EXISTS foo -- fully parenthetized +CREATE SCHEMA IF NOT EXISTS foo -- literals removed +CREATE SCHEMA IF NOT EXISTS _ -- identifiers removed + +parse +CREATE SCHEMA foo +---- +CREATE SCHEMA foo +CREATE SCHEMA foo -- fully parenthetized +CREATE SCHEMA foo -- literals removed +CREATE SCHEMA _ -- identifiers removed + +parse +CREATE SCHEMA IF NOT EXISTS foo.bar +---- +CREATE SCHEMA IF NOT EXISTS foo.bar +CREATE SCHEMA IF NOT EXISTS foo.bar -- fully parenthetized +CREATE SCHEMA IF NOT EXISTS foo.bar -- literals removed +CREATE SCHEMA IF NOT EXISTS _._ -- identifiers removed + +parse +CREATE SCHEMA foo.bar +---- +CREATE SCHEMA foo.bar +CREATE SCHEMA foo.bar -- fully parenthetized +CREATE SCHEMA foo.bar -- literals removed +CREATE SCHEMA _._ -- identifiers removed + +parse +CREATE SCHEMA IF NOT EXISTS foo AUTHORIZATION foobar +---- +CREATE SCHEMA IF NOT EXISTS foo AUTHORIZATION foobar +CREATE SCHEMA IF NOT EXISTS foo AUTHORIZATION foobar -- fully parenthetized +CREATE SCHEMA IF NOT EXISTS foo AUTHORIZATION foobar -- literals removed +CREATE SCHEMA IF NOT EXISTS _ AUTHORIZATION _ -- identifiers removed + +parse +CREATE SCHEMA IF NOT EXISTS foo.bar AUTHORIZATION foobar +---- +CREATE SCHEMA IF NOT EXISTS foo.bar AUTHORIZATION foobar +CREATE SCHEMA IF NOT EXISTS foo.bar AUTHORIZATION foobar -- fully parenthetized +CREATE SCHEMA IF NOT EXISTS foo.bar AUTHORIZATION foobar -- literals removed +CREATE SCHEMA IF NOT EXISTS _._ AUTHORIZATION _ -- identifiers removed + +parse +CREATE SCHEMA foo AUTHORIZATION foobar +---- +CREATE SCHEMA foo AUTHORIZATION foobar +CREATE SCHEMA foo AUTHORIZATION foobar -- fully parenthetized +CREATE SCHEMA foo AUTHORIZATION foobar -- literals removed +CREATE SCHEMA _ AUTHORIZATION _ -- identifiers removed + +parse +CREATE SCHEMA foo.bar AUTHORIZATION foobar +---- +CREATE SCHEMA foo.bar AUTHORIZATION foobar +CREATE SCHEMA foo.bar AUTHORIZATION foobar -- fully parenthetized +CREATE SCHEMA foo.bar AUTHORIZATION foobar -- literals removed +CREATE SCHEMA _._ AUTHORIZATION _ -- identifiers removed + +parse +CREATE SCHEMA IF NOT EXISTS AUTHORIZATION foobar +---- +CREATE SCHEMA IF NOT EXISTS AUTHORIZATION foobar +CREATE SCHEMA IF NOT EXISTS AUTHORIZATION foobar -- fully parenthetized +CREATE SCHEMA IF NOT EXISTS AUTHORIZATION foobar -- literals removed +CREATE SCHEMA IF NOT EXISTS AUTHORIZATION _ -- identifiers removed + +parse +CREATE SCHEMA AUTHORIZATION foobar +---- +CREATE SCHEMA AUTHORIZATION foobar +CREATE SCHEMA AUTHORIZATION foobar -- fully parenthetized +CREATE SCHEMA AUTHORIZATION foobar -- literals removed +CREATE SCHEMA AUTHORIZATION _ -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/create_sequence b/pkg/sql/parser/testdata/parse/create_sequence new file mode 100644 index 000000000000..badfed87b6b5 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/create_sequence @@ -0,0 +1,186 @@ +parse +CREATE SEQUENCE a +---- +CREATE SEQUENCE a +CREATE SEQUENCE a -- fully parenthetized +CREATE SEQUENCE a -- literals removed +CREATE SEQUENCE _ -- identifiers removed + +parse +EXPLAIN CREATE SEQUENCE a +---- +EXPLAIN CREATE SEQUENCE a +EXPLAIN CREATE SEQUENCE a -- fully parenthetized +EXPLAIN CREATE SEQUENCE a -- literals removed +EXPLAIN CREATE SEQUENCE _ -- identifiers removed + +parse +CREATE SEQUENCE IF NOT EXISTS a +---- +CREATE SEQUENCE IF NOT EXISTS a +CREATE SEQUENCE IF NOT EXISTS a -- fully parenthetized +CREATE SEQUENCE IF NOT EXISTS a -- literals removed +CREATE SEQUENCE IF NOT EXISTS _ -- identifiers removed + +parse +CREATE SEQUENCE a CYCLE +---- +CREATE SEQUENCE a CYCLE +CREATE SEQUENCE a CYCLE -- fully parenthetized +CREATE SEQUENCE a CYCLE -- literals removed +CREATE SEQUENCE _ CYCLE -- identifiers removed + +parse +CREATE SEQUENCE a NO CYCLE +---- +CREATE SEQUENCE a NO CYCLE +CREATE SEQUENCE a NO CYCLE -- fully parenthetized +CREATE SEQUENCE a NO CYCLE -- literals removed +CREATE SEQUENCE _ NO CYCLE -- identifiers removed + +parse +CREATE SEQUENCE a CACHE 0 +---- +CREATE SEQUENCE a CACHE 0 +CREATE SEQUENCE a CACHE 0 -- fully parenthetized +CREATE SEQUENCE a CACHE _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE SEQUENCE _ CACHE 0 -- identifiers removed + +parse +CREATE SEQUENCE a CACHE 1 +---- +CREATE SEQUENCE a CACHE 1 +CREATE SEQUENCE a CACHE 1 -- fully parenthetized +CREATE SEQUENCE a CACHE _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE SEQUENCE _ CACHE 1 -- identifiers removed + +parse +CREATE SEQUENCE a CACHE 2 +---- +CREATE SEQUENCE a CACHE 2 +CREATE SEQUENCE a CACHE 2 -- fully parenthetized +CREATE SEQUENCE a CACHE _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE SEQUENCE _ CACHE 2 -- identifiers removed + +parse +CREATE SEQUENCE a INCREMENT 5 +---- +CREATE SEQUENCE a INCREMENT 5 +CREATE SEQUENCE a INCREMENT 5 -- fully parenthetized +CREATE SEQUENCE a INCREMENT _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE SEQUENCE _ INCREMENT 5 -- identifiers removed + +parse +CREATE SEQUENCE a INCREMENT BY 5 +---- +CREATE SEQUENCE a INCREMENT BY 5 +CREATE SEQUENCE a INCREMENT BY 5 -- fully parenthetized +CREATE SEQUENCE a INCREMENT BY _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE SEQUENCE _ INCREMENT BY 5 -- identifiers removed + +parse +CREATE SEQUENCE a NO MAXVALUE +---- +CREATE SEQUENCE a NO MAXVALUE +CREATE SEQUENCE a NO MAXVALUE -- fully parenthetized +CREATE SEQUENCE a NO MAXVALUE -- literals removed +CREATE SEQUENCE _ NO MAXVALUE -- identifiers removed + +parse +CREATE SEQUENCE a MAXVALUE 1000 +---- +CREATE SEQUENCE a MAXVALUE 1000 +CREATE SEQUENCE a MAXVALUE 1000 -- fully parenthetized +CREATE SEQUENCE a MAXVALUE _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE SEQUENCE _ MAXVALUE 1000 -- identifiers removed + +parse +CREATE SEQUENCE a NO MINVALUE +---- +CREATE SEQUENCE a NO MINVALUE +CREATE SEQUENCE a NO MINVALUE -- fully parenthetized +CREATE SEQUENCE a NO MINVALUE -- literals removed +CREATE SEQUENCE _ NO MINVALUE -- identifiers removed + +parse +CREATE SEQUENCE a MINVALUE 1000 +---- +CREATE SEQUENCE a MINVALUE 1000 +CREATE SEQUENCE a MINVALUE 1000 -- fully parenthetized +CREATE SEQUENCE a MINVALUE _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE SEQUENCE _ MINVALUE 1000 -- identifiers removed + +parse +CREATE SEQUENCE a START 1000 +---- +CREATE SEQUENCE a START 1000 +CREATE SEQUENCE a START 1000 -- fully parenthetized +CREATE SEQUENCE a START _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE SEQUENCE _ START 1000 -- identifiers removed + +parse +CREATE SEQUENCE a START WITH 1000 +---- +CREATE SEQUENCE a START WITH 1000 +CREATE SEQUENCE a START WITH 1000 -- fully parenthetized +CREATE SEQUENCE a START WITH _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE SEQUENCE _ START WITH 1000 -- identifiers removed + +parse +CREATE SEQUENCE a INCREMENT 5 NO MAXVALUE MINVALUE 1 START 3 +---- +CREATE SEQUENCE a INCREMENT 5 NO MAXVALUE MINVALUE 1 START 3 +CREATE SEQUENCE a INCREMENT 5 NO MAXVALUE MINVALUE 1 START 3 -- fully parenthetized +CREATE SEQUENCE a INCREMENT _ NO MAXVALUE MINVALUE _ START _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE SEQUENCE _ INCREMENT 5 NO MAXVALUE MINVALUE 1 START 3 -- identifiers removed + +parse +CREATE SEQUENCE a INCREMENT 5 NO CYCLE NO MAXVALUE MINVALUE 1 START 3 CACHE 1 +---- +CREATE SEQUENCE a INCREMENT 5 NO CYCLE NO MAXVALUE MINVALUE 1 START 3 CACHE 1 +CREATE SEQUENCE a INCREMENT 5 NO CYCLE NO MAXVALUE MINVALUE 1 START 3 CACHE 1 -- fully parenthetized +CREATE SEQUENCE a INCREMENT _ NO CYCLE NO MAXVALUE MINVALUE _ START _ CACHE _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +CREATE SEQUENCE _ INCREMENT 5 NO CYCLE NO MAXVALUE MINVALUE 1 START 3 CACHE 1 -- identifiers removed + +parse +CREATE SEQUENCE a VIRTUAL +---- +CREATE SEQUENCE a VIRTUAL +CREATE SEQUENCE a VIRTUAL -- fully parenthetized +CREATE SEQUENCE a VIRTUAL -- literals removed +CREATE SEQUENCE _ VIRTUAL -- identifiers removed + +parse +CREATE TEMPORARY SEQUENCE a +---- +CREATE TEMPORARY SEQUENCE a +CREATE TEMPORARY SEQUENCE a -- fully parenthetized +CREATE TEMPORARY SEQUENCE a -- literals removed +CREATE TEMPORARY SEQUENCE _ -- identifiers removed + +parse +CREATE SEQUENCE a OWNED BY b +---- +CREATE SEQUENCE a OWNED BY b +CREATE SEQUENCE a OWNED BY (b) -- fully parenthetized +CREATE SEQUENCE a OWNED BY b -- literals removed +CREATE SEQUENCE _ OWNED BY _ -- identifiers removed + +parse +CREATE SEQUENCE a OWNED BY NONE +---- +CREATE SEQUENCE a OWNED BY NONE +CREATE SEQUENCE a OWNED BY NONE -- fully parenthetized +CREATE SEQUENCE a OWNED BY NONE -- literals removed +CREATE SEQUENCE _ OWNED BY NONE -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/create_table b/pkg/sql/parser/testdata/parse/create_table new file mode 100644 index 000000000000..ec5b3b43616a --- /dev/null +++ b/pkg/sql/parser/testdata/parse/create_table @@ -0,0 +1,2136 @@ +parse +CREATE TABLE a () +---- +CREATE TABLE a () +CREATE TABLE a () -- fully parenthetized +CREATE TABLE a () -- literals removed +CREATE TABLE _ () -- identifiers removed + +parse +CREATE TABLE FAMILY (x INT) +---- +CREATE TABLE "family" (x INT8) -- normalized! +CREATE TABLE "family" (x INT8) -- fully parenthetized +CREATE TABLE "family" (x INT8) -- literals removed +CREATE TABLE _ (_ INT8) -- identifiers removed + +parse +CREATE TABLE INDEX (x INT) +---- +CREATE TABLE "index" (x INT8) -- normalized! +CREATE TABLE "index" (x INT8) -- fully parenthetized +CREATE TABLE "index" (x INT8) -- literals removed +CREATE TABLE _ (_ INT8) -- identifiers removed + +parse +CREATE TABLE NOTHING (x INT) +---- +CREATE TABLE "nothing" (x INT8) -- normalized! +CREATE TABLE "nothing" (x INT8) -- fully parenthetized +CREATE TABLE "nothing" (x INT8) -- literals removed +CREATE TABLE _ (_ INT8) -- identifiers removed + +parse +CREATE TABLE MINVALUE (x INT) +---- +CREATE TABLE minvalue (x INT8) -- normalized! +CREATE TABLE minvalue (x INT8) -- fully parenthetized +CREATE TABLE minvalue (x INT8) -- literals removed +CREATE TABLE _ (_ INT8) -- identifiers removed + +parse +CREATE TABLE MAXVALUE (x INT) +---- +CREATE TABLE maxvalue (x INT8) -- normalized! +CREATE TABLE maxvalue (x INT8) -- fully parenthetized +CREATE TABLE maxvalue (x INT8) -- literals removed +CREATE TABLE _ (_ INT8) -- identifiers removed + +parse +CREATE TABLE foo (MINVALUE INT) +---- +CREATE TABLE foo (minvalue INT8) -- normalized! +CREATE TABLE foo (minvalue INT8) -- fully parenthetized +CREATE TABLE foo (minvalue INT8) -- literals removed +CREATE TABLE _ (_ INT8) -- identifiers removed + +parse +CREATE TABLE foo (MAXVALUE INT) +---- +CREATE TABLE foo (maxvalue INT8) -- normalized! +CREATE TABLE foo (maxvalue INT8) -- fully parenthetized +CREATE TABLE foo (maxvalue INT8) -- literals removed +CREATE TABLE _ (_ INT8) -- identifiers removed + +parse +CREATE TEMPORARY TABLE a (b INT8) +---- +CREATE TEMPORARY TABLE a (b INT8) +CREATE TEMPORARY TABLE a (b INT8) -- fully parenthetized +CREATE TEMPORARY TABLE a (b INT8) -- literals removed +CREATE TEMPORARY TABLE _ (_ INT8) -- identifiers removed + +parse +CREATE UNLOGGED TABLE a (b INT8) +---- +CREATE UNLOGGED TABLE a (b INT8) +CREATE UNLOGGED TABLE a (b INT8) -- fully parenthetized +CREATE UNLOGGED TABLE a (b INT8) -- literals removed +CREATE UNLOGGED TABLE _ (_ INT8) -- identifiers removed + +parse +EXPLAIN CREATE TABLE a () +---- +EXPLAIN CREATE TABLE a () +EXPLAIN CREATE TABLE a () -- fully parenthetized +EXPLAIN CREATE TABLE a () -- literals removed +EXPLAIN CREATE TABLE _ () -- identifiers removed + +parse +CREATE TABLE a (b INT8) +---- +CREATE TABLE a (b INT8) +CREATE TABLE a (b INT8) -- fully parenthetized +CREATE TABLE a (b INT8) -- literals removed +CREATE TABLE _ (_ INT8) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c INT8) +---- +CREATE TABLE a (b INT8, c INT8) +CREATE TABLE a (b INT8, c INT8) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8) -- identifiers removed + +parse +CREATE TABLE a (b BIGINT, c SMALLINT, d INTEGER, e INT) +---- +CREATE TABLE a (b INT8, c INT2, d INT8, e INT8) -- normalized! +CREATE TABLE a (b INT8, c INT2, d INT8, e INT8) -- fully parenthetized +CREATE TABLE a (b INT8, c INT2, d INT8, e INT8) -- literals removed +CREATE TABLE _ (_ INT8, _ INT2, _ INT8, _ INT8) -- identifiers removed + + +parse +CREATE TABLE a (b CHAR) +---- +CREATE TABLE a (b CHAR) +CREATE TABLE a (b CHAR) -- fully parenthetized +CREATE TABLE a (b CHAR) -- literals removed +CREATE TABLE _ (_ CHAR) -- identifiers removed + +parse +CREATE TABLE a (b CHAR(3)) +---- +CREATE TABLE a (b CHAR(3)) +CREATE TABLE a (b CHAR(3)) -- fully parenthetized +CREATE TABLE a (b CHAR(3)) -- literals removed +CREATE TABLE _ (_ CHAR(3)) -- identifiers removed + +parse +CREATE TABLE a (b VARCHAR) +---- +CREATE TABLE a (b VARCHAR) +CREATE TABLE a (b VARCHAR) -- fully parenthetized +CREATE TABLE a (b VARCHAR) -- literals removed +CREATE TABLE _ (_ VARCHAR) -- identifiers removed + +parse +CREATE TABLE a (b VARCHAR(3)) +---- +CREATE TABLE a (b VARCHAR(3)) +CREATE TABLE a (b VARCHAR(3)) -- fully parenthetized +CREATE TABLE a (b VARCHAR(3)) -- literals removed +CREATE TABLE _ (_ VARCHAR(3)) -- identifiers removed + +parse +CREATE TABLE a (b STRING) +---- +CREATE TABLE a (b STRING) +CREATE TABLE a (b STRING) -- fully parenthetized +CREATE TABLE a (b STRING) -- literals removed +CREATE TABLE _ (_ STRING) -- identifiers removed + +parse +CREATE TABLE a (b STRING(3)) +---- +CREATE TABLE a (b STRING(3)) +CREATE TABLE a (b STRING(3)) -- fully parenthetized +CREATE TABLE a (b STRING(3)) -- literals removed +CREATE TABLE _ (_ STRING(3)) -- identifiers removed + +parse +CREATE TABLE a (b TEXT) +---- +CREATE TABLE a (b STRING) -- normalized! +CREATE TABLE a (b STRING) -- fully parenthetized +CREATE TABLE a (b STRING) -- literals removed +CREATE TABLE _ (_ STRING) -- identifiers removed + +parse +CREATE TABLE a (b CHAR(1), c CHARACTER(1), d CHARACTER(3)) +---- +CREATE TABLE a (b CHAR, c CHAR, d CHAR(3)) -- normalized! +CREATE TABLE a (b CHAR, c CHAR, d CHAR(3)) -- fully parenthetized +CREATE TABLE a (b CHAR, c CHAR, d CHAR(3)) -- literals removed +CREATE TABLE _ (_ CHAR, _ CHAR, _ CHAR(3)) -- identifiers removed + +parse +CREATE TABLE a (b CHAR VARYING, c CHARACTER VARYING(3)) +---- +CREATE TABLE a (b VARCHAR, c VARCHAR(3)) -- normalized! +CREATE TABLE a (b VARCHAR, c VARCHAR(3)) -- fully parenthetized +CREATE TABLE a (b VARCHAR, c VARCHAR(3)) -- literals removed +CREATE TABLE _ (_ VARCHAR, _ VARCHAR(3)) -- identifiers removed + +parse +CREATE TABLE a (b BIT VARYING(2), c BIT(1)) +---- +CREATE TABLE a (b VARBIT(2), c BIT) -- normalized! +CREATE TABLE a (b VARBIT(2), c BIT) -- fully parenthetized +CREATE TABLE a (b VARBIT(2), c BIT) -- literals removed +CREATE TABLE _ (_ VARBIT(2), _ BIT) -- identifiers removed + + +parse +CREATE TABLE a (b JSON) +---- +CREATE TABLE a (b JSONB) -- normalized! +CREATE TABLE a (b JSONB) -- fully parenthetized +CREATE TABLE a (b JSONB) -- literals removed +CREATE TABLE _ (_ JSONB) -- identifiers removed + + +parse +CREATE TABLE a (b FLOAT4) +---- +CREATE TABLE a (b FLOAT4) +CREATE TABLE a (b FLOAT4) -- fully parenthetized +CREATE TABLE a (b FLOAT4) -- literals removed +CREATE TABLE _ (_ FLOAT4) -- identifiers removed + +parse +CREATE TABLE a (b FLOAT8) +---- +CREATE TABLE a (b FLOAT8) +CREATE TABLE a (b FLOAT8) -- fully parenthetized +CREATE TABLE a (b FLOAT8) -- literals removed +CREATE TABLE _ (_ FLOAT8) -- identifiers removed + +parse +CREATE TABLE a (b FLOAT, c FLOAT(10), d FLOAT(40), e REAL, f DOUBLE PRECISION) +---- +CREATE TABLE a (b FLOAT8, c FLOAT4, d FLOAT8, e FLOAT4, f FLOAT8) -- normalized! +CREATE TABLE a (b FLOAT8, c FLOAT4, d FLOAT8, e FLOAT4, f FLOAT8) -- fully parenthetized +CREATE TABLE a (b FLOAT8, c FLOAT4, d FLOAT8, e FLOAT4, f FLOAT8) -- literals removed +CREATE TABLE _ (_ FLOAT8, _ FLOAT4, _ FLOAT8, _ FLOAT4, _ FLOAT8) -- identifiers removed + +parse +CREATE TABLE a (b NUMERIC, c NUMERIC(10), d DEC) +---- +CREATE TABLE a (b DECIMAL, c DECIMAL(10), d DECIMAL) -- normalized! +CREATE TABLE a (b DECIMAL, c DECIMAL(10), d DECIMAL) -- fully parenthetized +CREATE TABLE a (b DECIMAL, c DECIMAL(10), d DECIMAL) -- literals removed +CREATE TABLE _ (_ DECIMAL, _ DECIMAL(10), _ DECIMAL) -- identifiers removed + +parse +CREATE TABLE a (b BOOLEAN) +---- +CREATE TABLE a (b BOOL) -- normalized! +CREATE TABLE a (b BOOL) -- fully parenthetized +CREATE TABLE a (b BOOL) -- literals removed +CREATE TABLE _ (_ BOOL) -- identifiers removed + + +parse +CREATE TABLE a (b SERIAL8) +---- +CREATE TABLE a (b SERIAL8) +CREATE TABLE a (b SERIAL8) -- fully parenthetized +CREATE TABLE a (b SERIAL8) -- literals removed +CREATE TABLE _ (_ SERIAL8) -- identifiers removed + +parse +CREATE TABLE a (b BIGSERIAL, c SMALLSERIAL, d SERIAL) +---- +CREATE TABLE a (b SERIAL8, c SERIAL2, d SERIAL8) -- normalized! +CREATE TABLE a (b SERIAL8, c SERIAL2, d SERIAL8) -- fully parenthetized +CREATE TABLE a (b SERIAL8, c SERIAL2, d SERIAL8) -- literals removed +CREATE TABLE _ (_ SERIAL8, _ SERIAL2, _ SERIAL8) -- identifiers removed + +parse +CREATE TABLE a (b TIMESTAMP WITH TIME ZONE) +---- +CREATE TABLE a (b TIMESTAMPTZ) -- normalized! +CREATE TABLE a (b TIMESTAMPTZ) -- fully parenthetized +CREATE TABLE a (b TIMESTAMPTZ) -- literals removed +CREATE TABLE _ (_ TIMESTAMPTZ) -- identifiers removed + +parse +CREATE TABLE a (b BYTES, c BYTEA, d BLOB) +---- +CREATE TABLE a (b BYTES, c BYTES, d BYTES) -- normalized! +CREATE TABLE a (b BYTES, c BYTES, d BYTES) -- fully parenthetized +CREATE TABLE a (b BYTES, c BYTES, d BYTES) -- literals removed +CREATE TABLE _ (_ BYTES, _ BYTES, _ BYTES) -- identifiers removed + + +parse +CREATE TABLE a (b TIME) +---- +CREATE TABLE a (b TIME) +CREATE TABLE a (b TIME) -- fully parenthetized +CREATE TABLE a (b TIME) -- literals removed +CREATE TABLE _ (_ TIME) -- identifiers removed + +parse +CREATE TABLE a (b TIMETZ) +---- +CREATE TABLE a (b TIMETZ) +CREATE TABLE a (b TIMETZ) -- fully parenthetized +CREATE TABLE a (b TIMETZ) -- literals removed +CREATE TABLE _ (_ TIMETZ) -- identifiers removed + +parse +CREATE TABLE a (b TIME(3)) +---- +CREATE TABLE a (b TIME(3)) +CREATE TABLE a (b TIME(3)) -- fully parenthetized +CREATE TABLE a (b TIME(3)) -- literals removed +CREATE TABLE _ (_ TIME(3)) -- identifiers removed + +parse +CREATE TABLE a (b TIMETZ(3)) +---- +CREATE TABLE a (b TIMETZ(3)) +CREATE TABLE a (b TIMETZ(3)) -- fully parenthetized +CREATE TABLE a (b TIMETZ(3)) -- literals removed +CREATE TABLE _ (_ TIMETZ(3)) -- identifiers removed + +parse +CREATE TABLE a (b BOX2D) +---- +CREATE TABLE a (b BOX2D) +CREATE TABLE a (b BOX2D) -- fully parenthetized +CREATE TABLE a (b BOX2D) -- literals removed +CREATE TABLE _ (_ BOX2D) -- identifiers removed + +parse +CREATE TABLE a (b GEOGRAPHY) +---- +CREATE TABLE a (b GEOGRAPHY) +CREATE TABLE a (b GEOGRAPHY) -- fully parenthetized +CREATE TABLE a (b GEOGRAPHY) -- literals removed +CREATE TABLE _ (_ GEOGRAPHY) -- identifiers removed + +parse +CREATE TABLE a (b GEOGRAPHY(POINT)) +---- +CREATE TABLE a (b GEOGRAPHY(POINT)) +CREATE TABLE a (b GEOGRAPHY(POINT)) -- fully parenthetized +CREATE TABLE a (b GEOGRAPHY(POINT)) -- literals removed +CREATE TABLE _ (_ GEOGRAPHY(POINT)) -- identifiers removed + +parse +CREATE TABLE a (b GEOGRAPHY(POINT,4326)) +---- +CREATE TABLE a (b GEOGRAPHY(POINT,4326)) +CREATE TABLE a (b GEOGRAPHY(POINT,4326)) -- fully parenthetized +CREATE TABLE a (b GEOGRAPHY(POINT,4326)) -- literals removed +CREATE TABLE _ (_ GEOGRAPHY(POINT,4326)) -- identifiers removed + +parse +CREATE TABLE a (b GEOGRAPHY(LINESTRING,4326)) +---- +CREATE TABLE a (b GEOGRAPHY(LINESTRING,4326)) +CREATE TABLE a (b GEOGRAPHY(LINESTRING,4326)) -- fully parenthetized +CREATE TABLE a (b GEOGRAPHY(LINESTRING,4326)) -- literals removed +CREATE TABLE _ (_ GEOGRAPHY(LINESTRING,4326)) -- identifiers removed + +parse +CREATE TABLE a (b GEOGRAPHY(POLYGON,4326)) +---- +CREATE TABLE a (b GEOGRAPHY(POLYGON,4326)) +CREATE TABLE a (b GEOGRAPHY(POLYGON,4326)) -- fully parenthetized +CREATE TABLE a (b GEOGRAPHY(POLYGON,4326)) -- literals removed +CREATE TABLE _ (_ GEOGRAPHY(POLYGON,4326)) -- identifiers removed + +parse +CREATE TABLE a (b GEOGRAPHY(MULTIPOINT,4326)) +---- +CREATE TABLE a (b GEOGRAPHY(MULTIPOINT,4326)) +CREATE TABLE a (b GEOGRAPHY(MULTIPOINT,4326)) -- fully parenthetized +CREATE TABLE a (b GEOGRAPHY(MULTIPOINT,4326)) -- literals removed +CREATE TABLE _ (_ GEOGRAPHY(MULTIPOINT,4326)) -- identifiers removed + +parse +CREATE TABLE a (b GEOGRAPHY(MULTILINESTRING,4326)) +---- +CREATE TABLE a (b GEOGRAPHY(MULTILINESTRING,4326)) +CREATE TABLE a (b GEOGRAPHY(MULTILINESTRING,4326)) -- fully parenthetized +CREATE TABLE a (b GEOGRAPHY(MULTILINESTRING,4326)) -- literals removed +CREATE TABLE _ (_ GEOGRAPHY(MULTILINESTRING,4326)) -- identifiers removed + +parse +CREATE TABLE a (b GEOGRAPHY(MULTIPOLYGON,4326)) +---- +CREATE TABLE a (b GEOGRAPHY(MULTIPOLYGON,4326)) +CREATE TABLE a (b GEOGRAPHY(MULTIPOLYGON,4326)) -- fully parenthetized +CREATE TABLE a (b GEOGRAPHY(MULTIPOLYGON,4326)) -- literals removed +CREATE TABLE _ (_ GEOGRAPHY(MULTIPOLYGON,4326)) -- identifiers removed + +parse +CREATE TABLE a (b GEOGRAPHY(GEOMETRY,4326)) +---- +CREATE TABLE a (b GEOGRAPHY(GEOMETRY,4326)) +CREATE TABLE a (b GEOGRAPHY(GEOMETRY,4326)) -- fully parenthetized +CREATE TABLE a (b GEOGRAPHY(GEOMETRY,4326)) -- literals removed +CREATE TABLE _ (_ GEOGRAPHY(GEOMETRY,4326)) -- identifiers removed + +parse +CREATE TABLE a (b GEOGRAPHY(GEOMETRYCOLLECTION,4326)) +---- +CREATE TABLE a (b GEOGRAPHY(GEOMETRYCOLLECTION,4326)) +CREATE TABLE a (b GEOGRAPHY(GEOMETRYCOLLECTION,4326)) -- fully parenthetized +CREATE TABLE a (b GEOGRAPHY(GEOMETRYCOLLECTION,4326)) -- literals removed +CREATE TABLE _ (_ GEOGRAPHY(GEOMETRYCOLLECTION,4326)) -- identifiers removed + +parse +CREATE TABLE a (b GEOMETRY) +---- +CREATE TABLE a (b GEOMETRY) +CREATE TABLE a (b GEOMETRY) -- fully parenthetized +CREATE TABLE a (b GEOMETRY) -- literals removed +CREATE TABLE _ (_ GEOMETRY) -- identifiers removed + +parse +CREATE TABLE a (b GEOMETRY(POINT)) +---- +CREATE TABLE a (b GEOMETRY(POINT)) +CREATE TABLE a (b GEOMETRY(POINT)) -- fully parenthetized +CREATE TABLE a (b GEOMETRY(POINT)) -- literals removed +CREATE TABLE _ (_ GEOMETRY(POINT)) -- identifiers removed + +parse +CREATE TABLE a (b GEOMETRY(POINT,4326)) +---- +CREATE TABLE a (b GEOMETRY(POINT,4326)) +CREATE TABLE a (b GEOMETRY(POINT,4326)) -- fully parenthetized +CREATE TABLE a (b GEOMETRY(POINT,4326)) -- literals removed +CREATE TABLE _ (_ GEOMETRY(POINT,4326)) -- identifiers removed + +parse +CREATE TABLE a (b UUID) +---- +CREATE TABLE a (b UUID) +CREATE TABLE a (b UUID) -- fully parenthetized +CREATE TABLE a (b UUID) -- literals removed +CREATE TABLE _ (_ UUID) -- identifiers removed + +parse +CREATE TABLE a (b INET) +---- +CREATE TABLE a (b INET) +CREATE TABLE a (b INET) -- fully parenthetized +CREATE TABLE a (b INET) -- literals removed +CREATE TABLE _ (_ INET) -- identifiers removed + +parse +CREATE TABLE a (b "char") +---- +CREATE TABLE a (b "char") +CREATE TABLE a (b "char") -- fully parenthetized +CREATE TABLE a (b "char") -- literals removed +CREATE TABLE _ (_ "char") -- identifiers removed + +parse +CREATE TABLE a (b INT8 NULL) +---- +CREATE TABLE a (b INT8 NULL) +CREATE TABLE a (b INT8 NULL) -- fully parenthetized +CREATE TABLE a (b INT8 NULL) -- literals removed +CREATE TABLE _ (_ INT8 NULL) -- identifiers removed + +parse +CREATE TABLE a (b INT8 CONSTRAINT maybe NULL) +---- +CREATE TABLE a (b INT8 CONSTRAINT maybe NULL) +CREATE TABLE a (b INT8 CONSTRAINT maybe NULL) -- fully parenthetized +CREATE TABLE a (b INT8 CONSTRAINT maybe NULL) -- literals removed +CREATE TABLE _ (_ INT8 CONSTRAINT _ NULL) -- identifiers removed + +parse +CREATE TABLE a (b INT8 NOT NULL) +---- +CREATE TABLE a (b INT8 NOT NULL) +CREATE TABLE a (b INT8 NOT NULL) -- fully parenthetized +CREATE TABLE a (b INT8 NOT NULL) -- literals removed +CREATE TABLE _ (_ INT8 NOT NULL) -- identifiers removed + +parse +CREATE TABLE a (b INT8 CONSTRAINT always NOT NULL) +---- +CREATE TABLE a (b INT8 CONSTRAINT always NOT NULL) +CREATE TABLE a (b INT8 CONSTRAINT always NOT NULL) -- fully parenthetized +CREATE TABLE a (b INT8 CONSTRAINT always NOT NULL) -- literals removed +CREATE TABLE _ (_ INT8 CONSTRAINT _ NOT NULL) -- identifiers removed + +parse +CREATE TABLE a (b INT8 PRIMARY KEY) +---- +CREATE TABLE a (b INT8 PRIMARY KEY) +CREATE TABLE a (b INT8 PRIMARY KEY) -- fully parenthetized +CREATE TABLE a (b INT8 PRIMARY KEY) -- literals removed +CREATE TABLE _ (_ INT8 PRIMARY KEY) -- identifiers removed + +parse +CREATE TABLE a (b INT8 UNIQUE) +---- +CREATE TABLE a (b INT8 UNIQUE) +CREATE TABLE a (b INT8 UNIQUE) -- fully parenthetized +CREATE TABLE a (b INT8 UNIQUE) -- literals removed +CREATE TABLE _ (_ INT8 UNIQUE) -- identifiers removed + +parse +CREATE TABLE a (b INT, UNIQUE INDEX foo (b)) +---- +CREATE TABLE a (b INT8, CONSTRAINT foo UNIQUE (b)) -- normalized! +CREATE TABLE a (b INT8, CONSTRAINT foo UNIQUE (b)) -- fully parenthetized +CREATE TABLE a (b INT8, CONSTRAINT foo UNIQUE (b)) -- literals removed +CREATE TABLE _ (_ INT8, CONSTRAINT _ UNIQUE (_)) -- identifiers removed + +parse +CREATE TABLE a (b INT, UNIQUE INDEX foo (b) WHERE c > 3) +---- +CREATE TABLE a (b INT8, CONSTRAINT foo UNIQUE (b) WHERE c > 3) -- normalized! +CREATE TABLE a (b INT8, CONSTRAINT foo UNIQUE (b) WHERE ((c) > (3))) -- fully parenthetized +CREATE TABLE a (b INT8, CONSTRAINT foo UNIQUE (b) WHERE c > _) -- literals removed +CREATE TABLE _ (_ INT8, CONSTRAINT _ UNIQUE (_) WHERE _ > 3) -- identifiers removed + +parse +CREATE TABLE a (b INT, UNIQUE INDEX foo (b) INTERLEAVE IN PARENT c (d)) +---- +CREATE TABLE a (b INT8, CONSTRAINT foo UNIQUE (b) INTERLEAVE IN PARENT c (d)) -- normalized! +CREATE TABLE a (b INT8, CONSTRAINT foo UNIQUE (b) INTERLEAVE IN PARENT c (d)) -- fully parenthetized +CREATE TABLE a (b INT8, CONSTRAINT foo UNIQUE (b) INTERLEAVE IN PARENT c (d)) -- literals removed +CREATE TABLE _ (_ INT8, CONSTRAINT _ UNIQUE (_) INTERLEAVE IN PARENT _ (_)) -- identifiers removed + +parse +CREATE TABLE a (UNIQUE 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))) -- normalized! +CREATE TABLE a (UNIQUE (b) PARTITION BY LIST (c) (PARTITION d VALUES IN ((1)))) -- fully parenthetized +CREATE TABLE a (UNIQUE (b) PARTITION BY LIST (c) (PARTITION d VALUES IN (_))) -- literals removed +CREATE TABLE _ (UNIQUE (_) PARTITION BY LIST (_) (PARTITION _ VALUES IN (1))) -- identifiers removed + +parse +CREATE TABLE a (b INT8 UNIQUE WITHOUT INDEX) +---- +CREATE TABLE a (b INT8 UNIQUE WITHOUT INDEX) +CREATE TABLE a (b INT8 UNIQUE WITHOUT INDEX) -- fully parenthetized +CREATE TABLE a (b INT8 UNIQUE WITHOUT INDEX) -- literals removed +CREATE TABLE _ (_ INT8 UNIQUE WITHOUT INDEX) -- identifiers removed + +parse +CREATE TABLE a (b INT8 NULL PRIMARY KEY) +---- +CREATE TABLE a (b INT8 NULL PRIMARY KEY) +CREATE TABLE a (b INT8 NULL PRIMARY KEY) -- fully parenthetized +CREATE TABLE a (b INT8 NULL PRIMARY KEY) -- literals removed +CREATE TABLE _ (_ INT8 NULL PRIMARY KEY) -- identifiers removed + +parse +CREATE TABLE a (b INT8 DEFAULT 1) +---- +CREATE TABLE a (b INT8 DEFAULT 1) +CREATE TABLE a (b INT8 DEFAULT (1)) -- fully parenthetized +CREATE TABLE a (b INT8 DEFAULT _) -- literals removed +CREATE TABLE _ (_ INT8 DEFAULT 1) -- identifiers removed + +parse +CREATE TABLE a (b INT8 CONSTRAINT one DEFAULT 1) +---- +CREATE TABLE a (b INT8 CONSTRAINT one DEFAULT 1) +CREATE TABLE a (b INT8 CONSTRAINT one DEFAULT (1)) -- fully parenthetized +CREATE TABLE a (b INT8 CONSTRAINT one DEFAULT _) -- literals removed +CREATE TABLE _ (_ INT8 CONSTRAINT _ DEFAULT 1) -- identifiers removed + +parse +CREATE TABLE a (b INT8 DEFAULT now()) +---- +CREATE TABLE a (b INT8 DEFAULT now()) +CREATE TABLE a (b INT8 DEFAULT ((now)())) -- fully parenthetized +CREATE TABLE a (b INT8 DEFAULT now()) -- literals removed +CREATE TABLE _ (_ INT8 DEFAULT now()) -- identifiers removed + +parse +CREATE TABLE a (a INT8 CHECK (a > 0)) +---- +CREATE TABLE a (a INT8 CHECK (a > 0)) +CREATE TABLE a (a INT8 CHECK (((a) > (0)))) -- fully parenthetized +CREATE TABLE a (a INT8 CHECK (a > _)) -- literals removed +CREATE TABLE _ (_ INT8 CHECK (_ > 0)) -- identifiers removed + +parse +CREATE TABLE a (a INT8 CONSTRAINT positive CHECK (a > 0)) +---- +CREATE TABLE a (a INT8 CONSTRAINT positive CHECK (a > 0)) +CREATE TABLE a (a INT8 CONSTRAINT positive CHECK (((a) > (0)))) -- fully parenthetized +CREATE TABLE a (a INT8 CONSTRAINT positive CHECK (a > _)) -- literals removed +CREATE TABLE _ (_ INT8 CONSTRAINT _ CHECK (_ > 0)) -- identifiers removed + +parse +CREATE TABLE a (a INT8 DEFAULT 1 CHECK (a > 0)) +---- +CREATE TABLE a (a INT8 DEFAULT 1 CHECK (a > 0)) +CREATE TABLE a (a INT8 DEFAULT (1) CHECK (((a) > (0)))) -- fully parenthetized +CREATE TABLE a (a INT8 DEFAULT _ CHECK (a > _)) -- literals removed +CREATE TABLE _ (_ INT8 DEFAULT 1 CHECK (_ > 0)) -- identifiers removed + +parse +CREATE TABLE a (a INT8 CONSTRAINT one DEFAULT 1 CHECK (a > 0)) +---- +CREATE TABLE a (a INT8 CONSTRAINT one DEFAULT 1 CHECK (a > 0)) +CREATE TABLE a (a INT8 CONSTRAINT one DEFAULT (1) CHECK (((a) > (0)))) -- fully parenthetized +CREATE TABLE a (a INT8 CONSTRAINT one DEFAULT _ CHECK (a > _)) -- literals removed +CREATE TABLE _ (_ INT8 CONSTRAINT _ DEFAULT 1 CHECK (_ > 0)) -- identifiers removed + +parse +CREATE TABLE a (a INT8 DEFAULT 1 CONSTRAINT positive CHECK (a > 0)) +---- +CREATE TABLE a (a INT8 DEFAULT 1 CONSTRAINT positive CHECK (a > 0)) +CREATE TABLE a (a INT8 DEFAULT (1) CONSTRAINT positive CHECK (((a) > (0)))) -- fully parenthetized +CREATE TABLE a (a INT8 DEFAULT _ CONSTRAINT positive CHECK (a > _)) -- literals removed +CREATE TABLE _ (_ INT8 DEFAULT 1 CONSTRAINT _ CHECK (_ > 0)) -- identifiers removed + +parse +CREATE TABLE a (a INT8 CONSTRAINT one 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 DEFAULT (1) CONSTRAINT positive CHECK (((a) > (0)))) -- fully parenthetized +CREATE TABLE a (a INT8 CONSTRAINT one DEFAULT _ CONSTRAINT positive CHECK (a > _)) -- literals removed +CREATE TABLE _ (_ INT8 CONSTRAINT _ DEFAULT 1 CONSTRAINT _ CHECK (_ > 0)) -- identifiers removed + +parse +CREATE TABLE a (a INT8 CONSTRAINT one CHECK (a > 0) CONSTRAINT two CHECK (a < 10)) +---- +CREATE TABLE a (a INT8 CONSTRAINT one CHECK (a > 0) CONSTRAINT two CHECK (a < 10)) +CREATE TABLE a (a INT8 CONSTRAINT one CHECK (((a) > (0))) CONSTRAINT two CHECK (((a) < (10)))) -- fully parenthetized +CREATE TABLE a (a INT8 CONSTRAINT one CHECK (a > _) CONSTRAINT two CHECK (a < _)) -- literals removed +CREATE TABLE _ (_ INT8 CONSTRAINT _ CHECK (_ > 0) CONSTRAINT _ CHECK (_ < 10)) -- identifiers removed + +parse +CREATE TABLE a (b INT, CHECK (b > 0) NOT VALID) +---- +CREATE TABLE a (b INT8, CHECK (b > 0)) -- normalized! +CREATE TABLE a (b INT8, CHECK (((b) > (0)))) -- fully parenthetized +CREATE TABLE a (b INT8, CHECK (b > _)) -- literals removed +CREATE TABLE _ (_ INT8, CHECK (_ > 0)) -- identifiers removed + + +parse +CREATE TABLE a (b INT8 NOT VISIBLE) +---- +CREATE TABLE a (b INT8 NOT VISIBLE) +CREATE TABLE a (b INT8 NOT VISIBLE) -- fully parenthetized +CREATE TABLE a (b INT8 NOT VISIBLE) -- literals removed +CREATE TABLE _ (_ INT8 NOT VISIBLE) -- identifiers removed + +parse +CREATE TABLE a (b INT8 NOT VISIBLE NULL) +---- +CREATE TABLE a (b INT8 NULL NOT VISIBLE) -- normalized! +CREATE TABLE a (b INT8 NULL NOT VISIBLE) -- fully parenthetized +CREATE TABLE a (b INT8 NULL NOT VISIBLE) -- literals removed +CREATE TABLE _ (_ INT8 NULL NOT VISIBLE) -- identifiers removed + +parse +CREATE TABLE a (b INT8 NULL NOT VISIBLE) +---- +CREATE TABLE a (b INT8 NULL NOT VISIBLE) +CREATE TABLE a (b INT8 NULL NOT VISIBLE) -- fully parenthetized +CREATE TABLE a (b INT8 NULL NOT VISIBLE) -- literals removed +CREATE TABLE _ (_ INT8 NULL NOT VISIBLE) -- identifiers removed + +parse +CREATE TABLE a (b INT8 CONSTRAINT c NOT NULL NOT VISIBLE) +---- +CREATE TABLE a (b INT8 CONSTRAINT c NOT NULL NOT VISIBLE) +CREATE TABLE a (b INT8 CONSTRAINT c NOT NULL NOT VISIBLE) -- fully parenthetized +CREATE TABLE a (b INT8 CONSTRAINT c NOT NULL NOT VISIBLE) -- literals removed +CREATE TABLE _ (_ INT8 CONSTRAINT _ NOT NULL NOT VISIBLE) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, PRIMARY KEY (b, c, "0")) +---- +CREATE TABLE a (b INT8, c STRING, PRIMARY KEY (b, c, "0")) +CREATE TABLE a (b INT8, c STRING, PRIMARY KEY (b, c, "0")) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, PRIMARY KEY (b, c, "0")) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, PRIMARY KEY (_, _, _)) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other) +---- +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _) -- identifiers removed + +parse +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 UPDATE RESTRICT) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON UPDATE RESTRICT) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON UPDATE RESTRICT) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ ON UPDATE RESTRICT) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c INT8 REFERENCES foo MATCH SIMPLE ON UPDATE RESTRICT) +---- +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE RESTRICT) -- normalized! +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE RESTRICT) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE RESTRICT) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ ON UPDATE RESTRICT) -- identifiers removed + +parse +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) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ ON DELETE RESTRICT) -- identifiers removed + +parse +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 DELETE RESTRICT ON UPDATE RESTRICT) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT ON UPDATE RESTRICT) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT ON UPDATE RESTRICT) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ ON DELETE RESTRICT ON UPDATE RESTRICT) -- identifiers removed + +parse +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 UPDATE CASCADE) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON UPDATE CASCADE) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON UPDATE CASCADE) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ ON UPDATE CASCADE) -- identifiers removed + +parse +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) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ ON DELETE CASCADE) -- identifiers removed + +parse +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 DELETE CASCADE ON UPDATE CASCADE) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE ON UPDATE CASCADE) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE ON UPDATE CASCADE) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ ON DELETE CASCADE ON UPDATE CASCADE) -- identifiers removed + +parse +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 UPDATE SET NULL) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON UPDATE SET NULL) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON UPDATE SET NULL) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ ON UPDATE SET NULL) -- identifiers removed + +parse +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) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ ON DELETE SET NULL) -- identifiers removed + +parse +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 DELETE SET NULL ON UPDATE SET NULL) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL ON UPDATE SET NULL) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL ON UPDATE SET NULL) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ ON DELETE SET NULL ON UPDATE SET NULL) -- identifiers removed + +parse +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 UPDATE SET DEFAULT) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON UPDATE SET DEFAULT) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON UPDATE SET DEFAULT) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ ON UPDATE SET DEFAULT) -- identifiers removed + +parse +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) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ ON DELETE SET DEFAULT) -- identifiers removed + +parse +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 SET DEFAULT ON UPDATE SET DEFAULT) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT ON UPDATE SET DEFAULT) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT ON UPDATE SET DEFAULT) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ ON DELETE SET DEFAULT ON UPDATE SET DEFAULT) -- identifiers removed + +parse +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 RESTRICT ON UPDATE SET DEFAULT) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT ON UPDATE SET DEFAULT) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT ON UPDATE SET DEFAULT) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ ON DELETE RESTRICT ON UPDATE SET DEFAULT) -- identifiers removed + +parse +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 SET DEFAULT ON UPDATE CASCADE) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT ON UPDATE CASCADE) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT ON UPDATE CASCADE) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ ON DELETE SET DEFAULT ON UPDATE CASCADE) -- identifiers removed + +parse +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 CASCADE ON UPDATE SET NULL) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE ON UPDATE SET NULL) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE ON UPDATE SET NULL) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ ON DELETE CASCADE ON UPDATE SET NULL) -- identifiers removed + +parse +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 ON DELETE SET NULL ON UPDATE RESTRICT) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL ON UPDATE RESTRICT) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL ON UPDATE RESTRICT) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ ON DELETE SET NULL ON UPDATE RESTRICT) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c INT8 REFERENCES foo MATCH SIMPLE) +---- +CREATE TABLE a (b INT8, c INT8 REFERENCES foo) -- normalized! +CREATE TABLE a (b INT8, c INT8 REFERENCES foo) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c INT8 REFERENCES foo (bar) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION) +---- +CREATE TABLE a (b INT8, c INT8 REFERENCES foo (bar)) -- normalized! +CREATE TABLE a (b INT8, c INT8 REFERENCES foo (bar)) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo (bar)) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ (_)) -- identifiers removed + +parse +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE NO ACTION ON DELETE NO ACTION) +---- +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other) -- normalized! +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other) -- fully parenthetized +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other) -- literals removed +CREATE TABLE _ (_ INT8, FOREIGN KEY (_) REFERENCES _) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other MATCH SIMPLE ON DELETE SET DEFAULT ON UPDATE SET DEFAULT) +---- +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT ON UPDATE SET DEFAULT) -- normalized! +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT ON UPDATE SET DEFAULT) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT ON UPDATE SET DEFAULT) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ ON DELETE SET DEFAULT ON UPDATE SET DEFAULT) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other MATCH SIMPLE ON DELETE RESTRICT ON UPDATE SET DEFAULT) +---- +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT ON UPDATE SET DEFAULT) -- normalized! +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT ON UPDATE SET DEFAULT) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT ON UPDATE SET DEFAULT) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ ON DELETE RESTRICT ON UPDATE SET DEFAULT) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other MATCH SIMPLE ON DELETE SET DEFAULT ON UPDATE CASCADE) +---- +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT ON UPDATE CASCADE) -- normalized! +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT ON UPDATE CASCADE) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT ON UPDATE CASCADE) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ ON DELETE SET DEFAULT ON UPDATE CASCADE) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other MATCH SIMPLE ON DELETE CASCADE ON UPDATE SET NULL) +---- +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE ON UPDATE SET NULL) -- normalized! +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE ON UPDATE SET NULL) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE ON UPDATE SET NULL) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ ON DELETE CASCADE ON UPDATE SET NULL) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other MATCH SIMPLE ON DELETE SET NULL ON UPDATE RESTRICT) +---- +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL ON UPDATE RESTRICT) -- normalized! +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL ON UPDATE RESTRICT) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL ON UPDATE RESTRICT) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ ON DELETE SET NULL ON UPDATE RESTRICT) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other MATCH SIMPLE) +---- +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other) -- normalized! +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_, _) REFERENCES _) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH SIMPLE) +---- +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y)) -- normalized! +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y)) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y)) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_, _) REFERENCES _ (_, _)) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH SIMPLE ON UPDATE CASCADE) +---- +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) ON UPDATE CASCADE) -- normalized! +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) ON UPDATE CASCADE) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) ON UPDATE CASCADE) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_, _) REFERENCES _ (_, _) ON UPDATE CASCADE) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH SIMPLE ON DELETE CASCADE) +---- +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) ON DELETE CASCADE) -- normalized! +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) ON DELETE CASCADE) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) ON DELETE CASCADE) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_, _) REFERENCES _ (_, _) ON DELETE CASCADE) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH SIMPLE ON DELETE CASCADE ON UPDATE SET NULL) +---- +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) ON DELETE CASCADE ON UPDATE SET NULL) -- normalized! +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) ON DELETE CASCADE ON UPDATE SET NULL) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) ON DELETE CASCADE ON UPDATE SET NULL) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_, _) REFERENCES _ (_, _) ON DELETE CASCADE ON UPDATE SET NULL) -- identifiers removed + + +parse +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE RESTRICT ON DELETE RESTRICT) +---- +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT ON UPDATE RESTRICT) -- normalized! +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT ON UPDATE RESTRICT) -- fully parenthetized +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT ON UPDATE RESTRICT) -- literals removed +CREATE TABLE _ (_ INT8, FOREIGN KEY (_) REFERENCES _ ON DELETE RESTRICT ON UPDATE RESTRICT) -- identifiers removed + +parse +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE RESTRICT ON DELETE NO ACTION) +---- +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE RESTRICT) -- normalized! +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE RESTRICT) -- fully parenthetized +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE RESTRICT) -- literals removed +CREATE TABLE _ (_ INT8, FOREIGN KEY (_) REFERENCES _ ON UPDATE RESTRICT) -- identifiers removed + +parse +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE NO ACTION ON DELETE RESTRICT) +---- +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT) -- normalized! +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT) -- fully parenthetized +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT) -- literals removed +CREATE TABLE _ (_ INT8, FOREIGN KEY (_) REFERENCES _ ON DELETE RESTRICT) -- identifiers removed + +parse +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE CASCADE ON DELETE CASCADE) +---- +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE ON UPDATE CASCADE) -- normalized! +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE ON UPDATE CASCADE) -- fully parenthetized +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE ON UPDATE CASCADE) -- literals removed +CREATE TABLE _ (_ INT8, FOREIGN KEY (_) REFERENCES _ ON DELETE CASCADE ON UPDATE CASCADE) -- identifiers removed + +parse +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE CASCADE ON DELETE NO ACTION) +---- +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE CASCADE) -- normalized! +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE CASCADE) -- fully parenthetized +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE CASCADE) -- literals removed +CREATE TABLE _ (_ INT8, FOREIGN KEY (_) REFERENCES _ ON UPDATE CASCADE) -- identifiers removed + +parse +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE NO ACTION ON DELETE CASCADE) +---- +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE) -- normalized! +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE) -- fully parenthetized +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE) -- literals removed +CREATE TABLE _ (_ INT8, FOREIGN KEY (_) REFERENCES _ ON DELETE CASCADE) -- identifiers removed + +parse +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE SET NULL ON DELETE SET NULL) +---- +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL ON UPDATE SET NULL) -- normalized! +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL ON UPDATE SET NULL) -- fully parenthetized +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL ON UPDATE SET NULL) -- literals removed +CREATE TABLE _ (_ INT8, FOREIGN KEY (_) REFERENCES _ ON DELETE SET NULL ON UPDATE SET NULL) -- identifiers removed + +parse +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE SET NULL ON DELETE NO ACTION) +---- +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE SET NULL) -- normalized! +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE SET NULL) -- fully parenthetized +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE SET NULL) -- literals removed +CREATE TABLE _ (_ INT8, FOREIGN KEY (_) REFERENCES _ ON UPDATE SET NULL) -- identifiers removed + +parse +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE NO ACTION ON DELETE SET NULL) +---- +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL) -- normalized! +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL) -- fully parenthetized +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL) -- literals removed +CREATE TABLE _ (_ INT8, FOREIGN KEY (_) REFERENCES _ ON DELETE SET NULL) -- identifiers removed + +parse +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE SET DEFAULT ON DELETE SET DEFAULT) +---- +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT ON UPDATE SET DEFAULT) -- normalized! +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT ON UPDATE SET DEFAULT) -- fully parenthetized +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT ON UPDATE SET DEFAULT) -- literals removed +CREATE TABLE _ (_ INT8, FOREIGN KEY (_) REFERENCES _ ON DELETE SET DEFAULT ON UPDATE SET DEFAULT) -- identifiers removed + +parse +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE SET DEFAULT ON DELETE NO ACTION) +---- +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE SET DEFAULT) -- normalized! +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE SET DEFAULT) -- fully parenthetized +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE SET DEFAULT) -- literals removed +CREATE TABLE _ (_ INT8, FOREIGN KEY (_) REFERENCES _ ON UPDATE SET DEFAULT) -- identifiers removed + +parse +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE NO ACTION ON DELETE SET DEFAULT) +---- +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT) -- normalized! +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT) -- fully parenthetized +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT) -- literals removed +CREATE TABLE _ (_ INT8, FOREIGN KEY (_) REFERENCES _ ON DELETE SET DEFAULT) -- identifiers removed + +parse +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE RESTRICT ON DELETE CASCADE) +---- +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE ON UPDATE RESTRICT) -- normalized! +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE ON UPDATE RESTRICT) -- fully parenthetized +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE CASCADE ON UPDATE RESTRICT) -- literals removed +CREATE TABLE _ (_ INT8, FOREIGN KEY (_) REFERENCES _ ON DELETE CASCADE ON UPDATE RESTRICT) -- identifiers removed + +parse +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE CASCADE ON DELETE SET NULL) +---- +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL ON UPDATE CASCADE) -- normalized! +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL ON UPDATE CASCADE) -- fully parenthetized +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET NULL ON UPDATE CASCADE) -- literals removed +CREATE TABLE _ (_ INT8, FOREIGN KEY (_) REFERENCES _ ON DELETE SET NULL ON UPDATE CASCADE) -- identifiers removed + +parse +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE SET NULL ON DELETE SET DEFAULT) +---- +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT ON UPDATE SET NULL) -- normalized! +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT ON UPDATE SET NULL) -- fully parenthetized +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE SET DEFAULT ON UPDATE SET NULL) -- literals removed +CREATE TABLE _ (_ INT8, FOREIGN KEY (_) REFERENCES _ ON DELETE SET DEFAULT ON UPDATE SET NULL) -- identifiers removed + +parse +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON UPDATE SET DEFAULT ON DELETE RESTRICT) +---- +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT ON UPDATE SET DEFAULT) -- normalized! +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT ON UPDATE SET DEFAULT) -- fully parenthetized +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other ON DELETE RESTRICT ON UPDATE SET DEFAULT) -- literals removed +CREATE TABLE _ (_ INT8, FOREIGN KEY (_) REFERENCES _ ON DELETE RESTRICT ON UPDATE SET DEFAULT) -- identifiers removed + +parse +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other MATCH FULL ON UPDATE NO ACTION ON DELETE NO ACTION) +---- +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other MATCH FULL) -- normalized! +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other MATCH FULL) -- fully parenthetized +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other MATCH FULL) -- literals removed +CREATE TABLE _ (_ INT8, FOREIGN KEY (_) REFERENCES _ MATCH FULL) -- identifiers removed + +parse +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 SET DEFAULT ON UPDATE SET DEFAULT) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other MATCH FULL ON DELETE SET DEFAULT ON UPDATE SET DEFAULT) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other MATCH FULL ON DELETE SET DEFAULT ON UPDATE SET DEFAULT) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ MATCH FULL ON DELETE SET DEFAULT ON UPDATE SET DEFAULT) -- identifiers removed + +parse +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 RESTRICT 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) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other MATCH FULL ON DELETE RESTRICT ON UPDATE SET DEFAULT) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ MATCH FULL ON DELETE RESTRICT ON UPDATE SET DEFAULT) -- identifiers removed + +parse +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 SET DEFAULT ON UPDATE CASCADE) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other MATCH FULL ON DELETE SET DEFAULT ON UPDATE CASCADE) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other MATCH FULL ON DELETE SET DEFAULT ON UPDATE CASCADE) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ MATCH FULL ON DELETE SET DEFAULT ON UPDATE CASCADE) -- identifiers removed + +parse +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 CASCADE ON UPDATE SET NULL) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other MATCH FULL ON DELETE CASCADE ON UPDATE SET NULL) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other MATCH FULL ON DELETE CASCADE ON UPDATE SET NULL) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ MATCH FULL ON DELETE CASCADE ON UPDATE SET NULL) -- identifiers removed + +parse +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) REFERENCES other MATCH FULL ON DELETE SET NULL ON UPDATE RESTRICT) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other MATCH FULL ON DELETE SET NULL ON UPDATE RESTRICT) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b) REFERENCES other MATCH FULL ON DELETE SET NULL ON UPDATE RESTRICT) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_) REFERENCES _ MATCH FULL ON DELETE SET NULL ON UPDATE RESTRICT) -- identifiers removed + +parse +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 MATCH FULL) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other MATCH FULL) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other MATCH FULL) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_, _) REFERENCES _ MATCH FULL) -- identifiers removed + +parse +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 (x, y) MATCH FULL) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH FULL) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH FULL) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_, _) REFERENCES _ (_, _) MATCH FULL) -- identifiers removed + +parse +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) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_, _) REFERENCES _) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y)) +---- +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y)) +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y)) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FOREIGN KEY (b, c) REFERENCES other (x, y)) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FOREIGN KEY (_, _) REFERENCES _ (_, _)) -- identifiers removed + +parse +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)) +CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y)) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y)) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, CONSTRAINT _ FOREIGN KEY (_, _) REFERENCES _ (_, _)) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH SIMPLE) +---- +CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y)) -- normalized! +CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y)) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y)) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, CONSTRAINT _ FOREIGN KEY (_, _) REFERENCES _ (_, _)) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH SIMPLE ON UPDATE SET NULL) +---- +CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) ON UPDATE SET NULL) -- normalized! +CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) ON UPDATE SET NULL) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) ON UPDATE SET NULL) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, CONSTRAINT _ FOREIGN KEY (_, _) REFERENCES _ (_, _) ON UPDATE SET NULL) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH SIMPLE ON DELETE SET DEFAULT) +---- +CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) ON DELETE SET DEFAULT) -- normalized! +CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) ON DELETE SET DEFAULT) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) ON DELETE SET DEFAULT) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, CONSTRAINT _ FOREIGN KEY (_, _) REFERENCES _ (_, _) ON DELETE SET DEFAULT) -- identifiers removed + +parse +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) +CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH FULL) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH FULL) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, CONSTRAINT _ FOREIGN KEY (_, _) REFERENCES _ (_, _) MATCH FULL) -- identifiers removed + +parse +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 UPDATE SET NULL) +CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH FULL ON UPDATE SET NULL) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH FULL ON UPDATE SET NULL) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, CONSTRAINT _ FOREIGN KEY (_, _) REFERENCES _ (_, _) MATCH FULL ON UPDATE SET NULL) -- identifiers removed + +parse +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) +CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH FULL ON DELETE SET DEFAULT) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH FULL ON DELETE SET DEFAULT) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, CONSTRAINT _ FOREIGN KEY (_, _) REFERENCES _ (_, _) MATCH FULL ON DELETE SET DEFAULT) -- identifiers removed + +parse +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, 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, CONSTRAINT s FOREIGN KEY (b, c) REFERENCES other (x, y) MATCH FULL ON DELETE SET DEFAULT ON UPDATE SET NULL) -- fully parenthetized +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) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, CONSTRAINT _ FOREIGN KEY (_, _) REFERENCES _ (_, _) MATCH FULL ON DELETE SET DEFAULT ON UPDATE SET NULL) -- identifiers removed + +parse +CREATE TABLE a (b INT, FOREIGN KEY (b) REFERENCES other (b) NOT VALID) +---- +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other (b)) -- normalized! +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other (b)) -- fully parenthetized +CREATE TABLE a (b INT8, FOREIGN KEY (b) REFERENCES other (b)) -- literals removed +CREATE TABLE _ (_ INT8, FOREIGN KEY (_) REFERENCES _ (_)) -- identifiers removed + + +parse +CREATE TABLE a (b INT8, c STRING, INDEX (b, c)) +---- +CREATE TABLE a (b INT8, c STRING, INDEX (b, c)) +CREATE TABLE a (b INT8, c STRING, INDEX (b, c)) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, INDEX (b, c)) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, INDEX (_, _)) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, INDEX d (b, c)) +---- +CREATE TABLE a (b INT8, c STRING, INDEX d (b, c)) +CREATE TABLE a (b INT8, c STRING, INDEX d (b, c)) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, INDEX d (b, c)) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, INDEX _ (_, _)) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, CONSTRAINT d UNIQUE (b, c)) +---- +CREATE TABLE a (b INT8, c STRING, CONSTRAINT d UNIQUE (b, c)) +CREATE TABLE a (b INT8, c STRING, CONSTRAINT d UNIQUE (b, c)) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, CONSTRAINT d UNIQUE (b, c)) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, CONSTRAINT _ UNIQUE (_, _)) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, CONSTRAINT d UNIQUE WITHOUT INDEX (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 WITHOUT INDEX (b, c)) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, CONSTRAINT d UNIQUE WITHOUT INDEX (b, c)) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, CONSTRAINT _ UNIQUE WITHOUT INDEX (_, _)) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, CONSTRAINT d UNIQUE (b, c) INTERLEAVE IN PARENT d (e, f)) +---- +CREATE TABLE a (b INT8, c STRING, CONSTRAINT d UNIQUE (b, c) INTERLEAVE IN PARENT d (e, f)) +CREATE TABLE a (b INT8, c STRING, CONSTRAINT d UNIQUE (b, c) INTERLEAVE IN PARENT d (e, f)) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, CONSTRAINT d UNIQUE (b, c) INTERLEAVE IN PARENT d (e, f)) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, CONSTRAINT _ UNIQUE (_, _) INTERLEAVE IN PARENT _ (_, _)) -- identifiers removed + +parse +CREATE TABLE a (b INT8, UNIQUE (b)) +---- +CREATE TABLE a (b INT8, UNIQUE (b)) +CREATE TABLE a (b INT8, UNIQUE (b)) -- fully parenthetized +CREATE TABLE a (b INT8, UNIQUE (b)) -- literals removed +CREATE TABLE _ (_ INT8, UNIQUE (_)) -- identifiers removed + +parse +CREATE TABLE a (b INT8, UNIQUE (b) STORING (c)) +---- +CREATE TABLE a (b INT8, UNIQUE (b) STORING (c)) +CREATE TABLE a (b INT8, UNIQUE (b) STORING (c)) -- fully parenthetized +CREATE TABLE a (b INT8, UNIQUE (b) STORING (c)) -- literals removed +CREATE TABLE _ (_ INT8, UNIQUE (_) STORING (_)) -- identifiers removed + +parse +CREATE TABLE a (b INT8, INDEX (b)) +---- +CREATE TABLE a (b INT8, INDEX (b)) +CREATE TABLE a (b INT8, INDEX (b)) -- fully parenthetized +CREATE TABLE a (b INT8, INDEX (b)) -- literals removed +CREATE TABLE _ (_ INT8, INDEX (_)) -- identifiers removed + +parse +CREATE TABLE a (b INT8, INVERTED INDEX (b)) +---- +CREATE TABLE a (b INT8, INVERTED INDEX (b)) +CREATE TABLE a (b INT8, INVERTED INDEX (b)) -- fully parenthetized +CREATE TABLE a (b INT8, INVERTED INDEX (b)) -- literals removed +CREATE TABLE _ (_ INT8, INVERTED INDEX (_)) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c INT8 REFERENCES foo) +---- +CREATE TABLE a (b INT8, c INT8 REFERENCES foo) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE RESTRICT) +---- +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE RESTRICT) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE RESTRICT) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE RESTRICT) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ ON UPDATE RESTRICT) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE 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) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE RESTRICT) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ ON DELETE RESTRICT) -- identifiers removed + +parse +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 DELETE RESTRICT ON UPDATE RESTRICT) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE RESTRICT ON UPDATE RESTRICT) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE RESTRICT ON UPDATE RESTRICT) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ ON DELETE RESTRICT ON UPDATE RESTRICT) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE CASCADE) +---- +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE CASCADE) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE CASCADE) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE CASCADE) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ ON UPDATE CASCADE) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE 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) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE CASCADE) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ ON DELETE CASCADE) -- identifiers removed + +parse +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 DELETE CASCADE ON UPDATE CASCADE) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE CASCADE ON UPDATE CASCADE) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE CASCADE ON UPDATE CASCADE) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ ON DELETE CASCADE ON UPDATE CASCADE) -- identifiers removed + +parse +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 NULL) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE SET NULL) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE SET NULL) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ ON UPDATE SET NULL) -- identifiers removed + +parse +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) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE SET NULL) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE SET NULL) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ ON DELETE SET NULL) -- identifiers removed + +parse +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 DELETE SET NULL ON UPDATE SET NULL) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE SET NULL ON UPDATE SET NULL) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE SET NULL ON UPDATE SET NULL) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ ON DELETE SET NULL ON UPDATE SET NULL) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE SET DEFAULT) +---- +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE SET DEFAULT) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE SET DEFAULT) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE SET DEFAULT) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ ON UPDATE SET DEFAULT) -- identifiers removed + +parse +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) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE SET DEFAULT) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE SET DEFAULT) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ ON DELETE SET DEFAULT) -- identifiers removed + +parse +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 SET DEFAULT ON UPDATE SET DEFAULT) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE SET DEFAULT ON UPDATE SET DEFAULT) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE SET DEFAULT ON UPDATE SET DEFAULT) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ ON DELETE SET DEFAULT ON UPDATE SET DEFAULT) -- identifiers removed + +parse +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 RESTRICT ON UPDATE SET DEFAULT) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE RESTRICT ON UPDATE SET DEFAULT) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE RESTRICT ON UPDATE SET DEFAULT) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ ON DELETE RESTRICT ON UPDATE SET DEFAULT) -- identifiers removed + +parse +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 SET DEFAULT ON UPDATE CASCADE) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE SET DEFAULT ON UPDATE CASCADE) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE SET DEFAULT ON UPDATE CASCADE) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ ON DELETE SET DEFAULT ON UPDATE CASCADE) -- identifiers removed + +parse +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 CASCADE ON UPDATE SET NULL) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE CASCADE ON UPDATE SET NULL) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE CASCADE ON UPDATE SET NULL) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ ON DELETE CASCADE ON UPDATE SET NULL) -- identifiers removed + +parse +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 DELETE SET NULL ON UPDATE RESTRICT) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE SET NULL ON UPDATE RESTRICT) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON DELETE SET NULL ON UPDATE RESTRICT) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ ON DELETE SET NULL ON UPDATE RESTRICT) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE CASCADE) +---- +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE CASCADE) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE CASCADE) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE CASCADE) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ ON UPDATE CASCADE) -- identifiers removed + +parse +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 NULL) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE SET NULL) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE SET NULL) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ ON UPDATE SET NULL) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE SET DEFAULT) +---- +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE SET DEFAULT) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE SET DEFAULT) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo ON UPDATE SET DEFAULT) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ ON UPDATE SET DEFAULT) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c INT8 REFERENCES foo (bar)) +---- +CREATE TABLE a (b INT8, c INT8 REFERENCES foo (bar)) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo (bar)) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo (bar)) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ (_)) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c INT8 REFERENCES foo MATCH FULL) +---- +CREATE TABLE a (b INT8, c INT8 REFERENCES foo MATCH FULL) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo MATCH FULL) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo MATCH FULL) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ MATCH FULL) -- identifiers removed + +parse +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 UPDATE RESTRICT) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo MATCH FULL ON UPDATE RESTRICT) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo MATCH FULL ON UPDATE RESTRICT) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ MATCH FULL ON UPDATE RESTRICT) -- identifiers removed + +parse +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) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo MATCH FULL ON DELETE RESTRICT) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo MATCH FULL ON DELETE RESTRICT) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ MATCH FULL ON DELETE RESTRICT) -- identifiers removed + +parse +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 MATCH FULL ON DELETE RESTRICT ON UPDATE RESTRICT) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo MATCH FULL ON DELETE RESTRICT ON UPDATE RESTRICT) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo MATCH FULL ON DELETE RESTRICT ON UPDATE RESTRICT) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ MATCH FULL ON DELETE RESTRICT ON UPDATE RESTRICT) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c INT8 REFERENCES foo (bar) MATCH FULL) +---- +CREATE TABLE a (b INT8, c INT8 REFERENCES foo (bar) MATCH FULL) +CREATE TABLE a (b INT8, c INT8 REFERENCES foo (bar) MATCH FULL) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8 REFERENCES foo (bar) MATCH FULL) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8 REFERENCES _ (_) MATCH FULL) -- identifiers removed + +parse +CREATE TABLE a (b INT8, INDEX (b) STORING (c)) +---- +CREATE TABLE a (b INT8, INDEX (b) STORING (c)) +CREATE TABLE a (b INT8, INDEX (b) STORING (c)) -- fully parenthetized +CREATE TABLE a (b INT8, INDEX (b) STORING (c)) -- literals removed +CREATE TABLE _ (_ INT8, INDEX (_) STORING (_)) -- identifiers removed + +parse +CREATE TABLE a (b INT8, INDEX (b) WHERE b > 3) +---- +CREATE TABLE a (b INT8, INDEX (b) WHERE b > 3) +CREATE TABLE a (b INT8, INDEX (b) WHERE ((b) > (3))) -- fully parenthetized +CREATE TABLE a (b INT8, INDEX (b) WHERE b > _) -- literals removed +CREATE TABLE _ (_ INT8, INDEX (_) WHERE _ > 3) -- identifiers removed + +parse +CREATE TABLE a (b INT8, INVERTED INDEX (b) WHERE b > 3) +---- +CREATE TABLE a (b INT8, INVERTED INDEX (b) WHERE b > 3) +CREATE TABLE a (b INT8, INVERTED INDEX (b) WHERE ((b) > (3))) -- fully parenthetized +CREATE TABLE a (b INT8, INVERTED INDEX (b) WHERE b > _) -- literals removed +CREATE TABLE _ (_ INT8, INVERTED INDEX (_) WHERE _ > 3) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, INDEX (b ASC, c DESC) STORING (c)) +---- +CREATE TABLE a (b INT8, c STRING, INDEX (b ASC, c DESC) STORING (c)) +CREATE TABLE a (b INT8, c STRING, INDEX (b ASC, c DESC) STORING (c)) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, INDEX (b ASC, c DESC) STORING (c)) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, INDEX (_ ASC, _ DESC) STORING (_)) -- identifiers removed + +parse +CREATE TABLE a (b INT8, INDEX (b) INTERLEAVE IN PARENT c (d, e)) +---- +CREATE TABLE a (b INT8, INDEX (b) INTERLEAVE IN PARENT c (d, e)) +CREATE TABLE a (b INT8, INDEX (b) INTERLEAVE IN PARENT c (d, e)) -- fully parenthetized +CREATE TABLE a (b INT8, INDEX (b) INTERLEAVE IN PARENT c (d, e)) -- literals removed +CREATE TABLE _ (_ INT8, INDEX (_) INTERLEAVE IN PARENT _ (_, _)) -- identifiers removed + +parse +CREATE TABLE a (b INT8, FAMILY (b)) +---- +CREATE TABLE a (b INT8, FAMILY (b)) +CREATE TABLE a (b INT8, FAMILY (b)) -- fully parenthetized +CREATE TABLE a (b INT8, FAMILY (b)) -- literals removed +CREATE TABLE _ (_ INT8, FAMILY (_)) -- identifiers removed + +parse +CREATE TABLE a (b INT8, c STRING, FAMILY foo (b), FAMILY (c)) +---- +CREATE TABLE a (b INT8, c STRING, FAMILY foo (b), FAMILY (c)) +CREATE TABLE a (b INT8, c STRING, FAMILY foo (b), FAMILY (c)) -- fully parenthetized +CREATE TABLE a (b INT8, c STRING, FAMILY foo (b), FAMILY (c)) -- literals removed +CREATE TABLE _ (_ INT8, _ STRING, FAMILY _ (_), FAMILY (_)) -- identifiers removed + +parse +CREATE TABLE a (b INT8) INTERLEAVE IN PARENT foo (c, d) +---- +CREATE TABLE a (b INT8) INTERLEAVE IN PARENT foo (c, d) +CREATE TABLE a (b INT8) INTERLEAVE IN PARENT foo (c, d) -- fully parenthetized +CREATE TABLE a (b INT8) INTERLEAVE IN PARENT foo (c, d) -- literals removed +CREATE TABLE _ (_ INT8) INTERLEAVE IN PARENT _ (_, _) -- identifiers removed + +parse +CREATE TABLE a (b INT8) INTERLEAVE IN PARENT foo (c) CASCADE +---- +CREATE TABLE a (b INT8) INTERLEAVE IN PARENT foo (c) CASCADE +CREATE TABLE a (b INT8) INTERLEAVE IN PARENT foo (c) CASCADE -- fully parenthetized +CREATE TABLE a (b INT8) INTERLEAVE IN PARENT foo (c) CASCADE -- literals removed +CREATE TABLE _ (_ INT8) INTERLEAVE IN PARENT _ (_) CASCADE -- identifiers removed + +parse +CREATE TABLE a.b (b INT8) +---- +CREATE TABLE a.b (b INT8) +CREATE TABLE a.b (b INT8) -- fully parenthetized +CREATE TABLE a.b (b INT8) -- literals removed +CREATE TABLE _._ (_ INT8) -- identifiers removed + +parse +CREATE TABLE IF NOT EXISTS a (b INT8) +---- +CREATE TABLE IF NOT EXISTS a (b INT8) +CREATE TABLE IF NOT EXISTS a (b INT8) -- fully parenthetized +CREATE TABLE IF NOT EXISTS a (b INT8) -- literals removed +CREATE TABLE IF NOT EXISTS _ (_ INT8) -- identifiers removed + +parse +CREATE TABLE a (b INT8 AS (a + b) STORED) +---- +CREATE TABLE a (b INT8 AS (a + b) STORED) +CREATE TABLE a (b INT8 AS (((a) + (b))) STORED) -- fully parenthetized +CREATE TABLE a (b INT8 AS (a + b) STORED) -- literals removed +CREATE TABLE _ (_ INT8 AS (_ + _) STORED) -- identifiers removed + +parse +CREATE TABLE a (b INT8 GENERATED ALWAYS AS (a + b) STORED) +---- +CREATE TABLE a (b INT8 AS (a + b) STORED) -- normalized! +CREATE TABLE a (b INT8 AS (((a) + (b))) STORED) -- fully parenthetized +CREATE TABLE a (b INT8 AS (a + b) STORED) -- literals removed +CREATE TABLE _ (_ INT8 AS (_ + _) STORED) -- identifiers removed + +parse +CREATE TABLE a (b INT8 GENERATED ALWAYS AS (a + b) VIRTUAL) +---- +CREATE TABLE a (b INT8 AS (a + b) VIRTUAL) -- normalized! +CREATE TABLE a (b INT8 AS (((a) + (b))) VIRTUAL) -- fully parenthetized +CREATE TABLE a (b INT8 AS (a + b) VIRTUAL) -- literals removed +CREATE TABLE _ (_ INT8 AS (_ + _) VIRTUAL) -- identifiers removed + +parse +CREATE TABLE a (b INT8 AS (a + b) VIRTUAL) +---- +CREATE TABLE a (b INT8 AS (a + b) VIRTUAL) +CREATE TABLE a (b INT8 AS (((a) + (b))) VIRTUAL) -- fully parenthetized +CREATE TABLE a (b INT8 AS (a + b) VIRTUAL) -- literals removed +CREATE TABLE _ (_ INT8 AS (_ + _) VIRTUAL) -- identifiers removed + +parse +CREATE TABLE view (view INT8) +---- +CREATE TABLE view (view INT8) +CREATE TABLE view (view INT8) -- fully parenthetized +CREATE TABLE view (view INT8) -- literals removed +CREATE TABLE _ (_ INT8) -- identifiers removed + +parse +CREATE TABLE a (b INT8 CONSTRAINT c PRIMARY KEY) +---- +CREATE TABLE a (b INT8 CONSTRAINT c PRIMARY KEY) +CREATE TABLE a (b INT8 CONSTRAINT c PRIMARY KEY) -- fully parenthetized +CREATE TABLE a (b INT8 CONSTRAINT c PRIMARY KEY) -- literals removed +CREATE TABLE _ (_ INT8 CONSTRAINT _ PRIMARY KEY) -- identifiers removed + +parse +CREATE TABLE a (b INT8 CONSTRAINT c NULL) +---- +CREATE TABLE a (b INT8 CONSTRAINT c NULL) +CREATE TABLE a (b INT8 CONSTRAINT c NULL) -- fully parenthetized +CREATE TABLE a (b INT8 CONSTRAINT c NULL) -- literals removed +CREATE TABLE _ (_ INT8 CONSTRAINT _ NULL) -- identifiers removed + +parse +CREATE TABLE a (b INT8 CONSTRAINT c UNIQUE) +---- +CREATE TABLE a (b INT8 CONSTRAINT c UNIQUE) +CREATE TABLE a (b INT8 CONSTRAINT c UNIQUE) -- fully parenthetized +CREATE TABLE a (b INT8 CONSTRAINT c UNIQUE) -- literals removed +CREATE TABLE _ (_ INT8 CONSTRAINT _ UNIQUE) -- identifiers removed + +parse +CREATE TABLE a (b INT8 CONSTRAINT c UNIQUE WITHOUT INDEX) +---- +CREATE TABLE a (b INT8 CONSTRAINT c UNIQUE WITHOUT INDEX) +CREATE TABLE a (b INT8 CONSTRAINT c UNIQUE WITHOUT INDEX) -- fully parenthetized +CREATE TABLE a (b INT8 CONSTRAINT c UNIQUE WITHOUT INDEX) -- literals removed +CREATE TABLE _ (_ INT8 CONSTRAINT _ UNIQUE WITHOUT INDEX) -- identifiers removed + +parse +CREATE TABLE a (b INT8 CONSTRAINT c DEFAULT d) +---- +CREATE TABLE a (b INT8 CONSTRAINT c DEFAULT d) +CREATE TABLE a (b INT8 CONSTRAINT c DEFAULT (d)) -- fully parenthetized +CREATE TABLE a (b INT8 CONSTRAINT c DEFAULT d) -- literals removed +CREATE TABLE _ (_ INT8 CONSTRAINT _ DEFAULT _) -- identifiers removed + +parse +CREATE TABLE a (b INT8 CONSTRAINT c CHECK (d)) +---- +CREATE TABLE a (b INT8 CONSTRAINT c CHECK (d)) +CREATE TABLE a (b INT8 CONSTRAINT c CHECK ((d))) -- fully parenthetized +CREATE TABLE a (b INT8 CONSTRAINT c CHECK (d)) -- literals removed +CREATE TABLE _ (_ INT8 CONSTRAINT _ CHECK (_)) -- identifiers removed + +parse +CREATE TABLE a (b INT8 CONSTRAINT c REFERENCES d) +---- +CREATE TABLE a (b INT8 CONSTRAINT c REFERENCES d) +CREATE TABLE a (b INT8 CONSTRAINT c REFERENCES d) -- fully parenthetized +CREATE TABLE a (b INT8 CONSTRAINT c REFERENCES d) -- literals removed +CREATE TABLE _ (_ INT8 CONSTRAINT _ REFERENCES _) -- identifiers removed + +parse +CREATE TABLE a (b INT8) PARTITION BY NOTHING +---- +CREATE TABLE a (b INT8) PARTITION BY NOTHING +CREATE TABLE a (b INT8) PARTITION BY NOTHING -- fully parenthetized +CREATE TABLE a (b INT8) PARTITION BY NOTHING -- literals removed +CREATE TABLE _ (_ INT8) PARTITION BY NOTHING -- identifiers removed + +parse +CREATE TABLE a (b INT8) PARTITION ALL BY NOTHING +---- +CREATE TABLE a (b INT8) PARTITION ALL BY NOTHING +CREATE TABLE a (b INT8) PARTITION ALL BY NOTHING -- fully parenthetized +CREATE TABLE a (b INT8) PARTITION ALL BY NOTHING -- literals removed +CREATE TABLE _ (_ INT8) PARTITION ALL BY NOTHING -- identifiers removed + +parse +CREATE TABLE a (b INT8) PARTITION BY LIST (b) (PARTITION p1 VALUES IN (1, DEFAULT), PARTITION p2 VALUES IN ((1, 2), (3, 4))) +---- +CREATE TABLE a (b INT8) PARTITION BY LIST (b) (PARTITION p1 VALUES IN (1, DEFAULT), PARTITION p2 VALUES IN ((1, 2), (3, 4))) +CREATE TABLE a (b INT8) PARTITION BY LIST (b) (PARTITION p1 VALUES IN ((1), (DEFAULT)), PARTITION p2 VALUES IN ((((1), (2))), (((3), (4))))) -- fully parenthetized +CREATE TABLE a (b INT8) PARTITION BY LIST (b) (PARTITION p1 VALUES IN (_, DEFAULT), PARTITION p2 VALUES IN ((_, _), (_, _))) -- literals removed +CREATE TABLE _ (_ INT8) PARTITION BY LIST (_) (PARTITION _ VALUES IN (1, DEFAULT), PARTITION _ VALUES IN ((1, 2), (3, 4))) -- identifiers removed + +parse +CREATE TABLE a (b INT8) PARTITION ALL BY LIST (b) (PARTITION p1 VALUES IN (1, DEFAULT), PARTITION p2 VALUES IN ((1, 2), (3, 4))) +---- +CREATE TABLE a (b INT8) PARTITION ALL BY LIST (b) (PARTITION p1 VALUES IN (1, DEFAULT), PARTITION p2 VALUES IN ((1, 2), (3, 4))) +CREATE TABLE a (b INT8) PARTITION ALL BY LIST (b) (PARTITION p1 VALUES IN ((1), (DEFAULT)), PARTITION p2 VALUES IN ((((1), (2))), (((3), (4))))) -- fully parenthetized +CREATE TABLE a (b INT8) PARTITION ALL BY LIST (b) (PARTITION p1 VALUES IN (_, DEFAULT), PARTITION p2 VALUES IN ((_, _), (_, _))) -- literals removed +CREATE TABLE _ (_ INT8) PARTITION ALL BY LIST (_) (PARTITION _ VALUES IN (1, DEFAULT), PARTITION _ VALUES IN ((1, 2), (3, 4))) -- identifiers removed + +parse +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 (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)))) -- normalized! +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))))) -- fully parenthetized +CREATE TABLE a (b INT8, c INT8, d INT8) PARTITION BY LIST (b) (PARTITION p1 VALUES IN (_) PARTITION BY LIST (c) (PARTITION p1_1 VALUES IN (_), PARTITION p1_2 VALUES IN (_, _)), PARTITION p2 VALUES IN (_) PARTITION BY RANGE (c) (PARTITION p2_1 VALUES FROM (_) TO (_) PARTITION BY LIST (d) (PARTITION p2_1_1 VALUES IN (_)))) -- literals removed +CREATE TABLE _ (_ INT8, _ INT8, _ INT8) PARTITION BY LIST (_) (PARTITION _ VALUES IN (1) PARTITION BY LIST (_) (PARTITION _ VALUES IN (3), PARTITION _ VALUES IN (4, 5)), PARTITION _ VALUES IN (6) PARTITION BY RANGE (_) (PARTITION _ VALUES FROM (7) TO (8) PARTITION BY LIST (_) (PARTITION _ VALUES IN (8)))) -- identifiers removed + +parse +CREATE TABLE a (b INT) PARTITION BY RANGE (b) ( + PARTITION p1 VALUES FROM (MINVALUE) TO (1), + PARTITION p2 VALUES FROM (2, MAXVALUE) TO (4, 4), + PARTITION p3 VALUES FROM (4, 4) TO (MAXVALUE)) +---- +CREATE TABLE a (b INT8) PARTITION BY RANGE (b) (PARTITION p1 VALUES FROM (minvalue) TO (1), PARTITION p2 VALUES FROM (2, maxvalue) TO (4, 4), PARTITION p3 VALUES FROM (4, 4) TO (maxvalue)) -- normalized! +CREATE TABLE a (b INT8) PARTITION BY RANGE (b) (PARTITION p1 VALUES FROM ((minvalue)) TO ((1)), PARTITION p2 VALUES FROM ((2), (maxvalue)) TO ((4), (4)), PARTITION p3 VALUES FROM ((4), (4)) TO ((maxvalue))) -- fully parenthetized +CREATE TABLE a (b INT8) PARTITION BY RANGE (b) (PARTITION p1 VALUES FROM (minvalue) TO (_), PARTITION p2 VALUES FROM (_, maxvalue) TO (_, _), PARTITION p3 VALUES FROM (_, _) TO (maxvalue)) -- literals removed +CREATE TABLE _ (_ INT8) PARTITION BY RANGE (_) (PARTITION _ VALUES FROM (_) TO (1), PARTITION _ VALUES FROM (2, _) TO (4, 4), PARTITION _ VALUES FROM (4, 4) TO (_)) -- identifiers removed + +parse +CREATE TABLE a (b INT) PARTITION ALL BY RANGE (b) ( + PARTITION p1 VALUES FROM (MINVALUE) TO (1), + PARTITION p2 VALUES FROM (2, MAXVALUE) TO (4, 4), + PARTITION p3 VALUES FROM (4, 4) TO (MAXVALUE)) +---- +CREATE TABLE a (b INT8) PARTITION ALL BY RANGE (b) (PARTITION p1 VALUES FROM (minvalue) TO (1), PARTITION p2 VALUES FROM (2, maxvalue) TO (4, 4), PARTITION p3 VALUES FROM (4, 4) TO (maxvalue)) -- normalized! +CREATE TABLE a (b INT8) PARTITION ALL BY RANGE (b) (PARTITION p1 VALUES FROM ((minvalue)) TO ((1)), PARTITION p2 VALUES FROM ((2), (maxvalue)) TO ((4), (4)), PARTITION p3 VALUES FROM ((4), (4)) TO ((maxvalue))) -- fully parenthetized +CREATE TABLE a (b INT8) PARTITION ALL BY RANGE (b) (PARTITION p1 VALUES FROM (minvalue) TO (_), PARTITION p2 VALUES FROM (_, maxvalue) TO (_, _), PARTITION p3 VALUES FROM (_, _) TO (maxvalue)) -- literals removed +CREATE TABLE _ (_ INT8) PARTITION ALL BY RANGE (_) (PARTITION _ VALUES FROM (_) TO (1), PARTITION _ VALUES FROM (2, _) TO (4, 4), PARTITION _ VALUES FROM (4, 4) TO (_)) -- identifiers removed + + +parse +CREATE TABLE a () INTERLEAVE IN PARENT b (c) PARTITION BY LIST (d) (PARTITION e VALUES IN (1)) +---- +CREATE TABLE a () INTERLEAVE IN PARENT b (c) PARTITION BY LIST (d) (PARTITION e VALUES IN (1)) +CREATE TABLE a () INTERLEAVE IN PARENT b (c) PARTITION BY LIST (d) (PARTITION e VALUES IN ((1))) -- fully parenthetized +CREATE TABLE a () INTERLEAVE IN PARENT b (c) PARTITION BY LIST (d) (PARTITION e VALUES IN (_)) -- literals removed +CREATE TABLE _ () INTERLEAVE IN PARENT _ (_) PARTITION BY LIST (_) (PARTITION _ VALUES IN (1)) -- identifiers removed + +parse +CREATE TABLE IF NOT EXISTS a () PARTITION BY LIST (b) (PARTITION c VALUES IN (1)) +---- +CREATE TABLE IF NOT EXISTS a () PARTITION BY LIST (b) (PARTITION c VALUES IN (1)) +CREATE TABLE IF NOT EXISTS a () PARTITION BY LIST (b) (PARTITION c VALUES IN ((1))) -- fully parenthetized +CREATE TABLE IF NOT EXISTS a () PARTITION BY LIST (b) (PARTITION c VALUES IN (_)) -- literals removed +CREATE TABLE IF NOT EXISTS _ () PARTITION BY LIST (_) (PARTITION _ VALUES IN (1)) -- identifiers removed + +parse +CREATE TABLE a (INDEX (b) PARTITION BY LIST (c) (PARTITION d VALUES IN (1))) +---- +CREATE TABLE a (INDEX (b) PARTITION BY LIST (c) (PARTITION d VALUES IN (1))) +CREATE TABLE a (INDEX (b) PARTITION BY LIST (c) (PARTITION d VALUES IN ((1)))) -- fully parenthetized +CREATE TABLE a (INDEX (b) PARTITION BY LIST (c) (PARTITION d VALUES IN (_))) -- literals removed +CREATE TABLE _ (INDEX (_) PARTITION BY LIST (_) (PARTITION _ VALUES IN (1))) -- identifiers removed + +parse +CREATE TABLE a (INVERTED INDEX (b) PARTITION BY LIST (c) (PARTITION d VALUES IN (1))) +---- +CREATE TABLE a (INVERTED INDEX (b) PARTITION BY LIST (c) (PARTITION d VALUES IN (1))) +CREATE TABLE a (INVERTED INDEX (b) PARTITION BY LIST (c) (PARTITION d VALUES IN ((1)))) -- fully parenthetized +CREATE TABLE a (INVERTED INDEX (b) PARTITION BY LIST (c) (PARTITION d VALUES IN (_))) -- literals removed +CREATE TABLE _ (INVERTED INDEX (_) PARTITION BY LIST (_) (PARTITION _ VALUES IN (1))) -- identifiers removed + +parse +CREATE TABLE a (UNIQUE (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 TABLE a (UNIQUE (b) PARTITION BY LIST (c) (PARTITION d VALUES IN ((1)))) -- fully parenthetized +CREATE TABLE a (UNIQUE (b) PARTITION BY LIST (c) (PARTITION d VALUES IN (_))) -- literals removed +CREATE TABLE _ (UNIQUE (_) PARTITION BY LIST (_) (PARTITION _ VALUES IN (1))) -- identifiers removed + +parse +CREATE INDEX ON a (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 ON a (b) PARTITION BY LIST (c) (PARTITION d VALUES IN ((1))) -- fully parenthetized +CREATE INDEX ON a (b) PARTITION BY LIST (c) (PARTITION d VALUES IN (_)) -- literals removed +CREATE INDEX ON _ (_) PARTITION BY LIST (_) (PARTITION _ VALUES IN (1)) -- identifiers removed + +parse +CREATE INVERTED INDEX ON a (b) PARTITION BY LIST (c) (PARTITION d VALUES IN (1)) +---- +CREATE INVERTED INDEX ON a (b) PARTITION BY LIST (c) (PARTITION d VALUES IN (1)) +CREATE INVERTED INDEX ON a (b) PARTITION BY LIST (c) (PARTITION d VALUES IN ((1))) -- fully parenthetized +CREATE INVERTED INDEX ON a (b) PARTITION BY LIST (c) (PARTITION d VALUES IN (_)) -- literals removed +CREATE INVERTED INDEX ON _ (_) PARTITION BY LIST (_) (PARTITION _ VALUES IN (1)) -- identifiers removed + +parse +CREATE INDEX IF NOT EXISTS a ON b (c) PARTITION BY LIST (d) (PARTITION e VALUES IN (1)) +---- +CREATE INDEX IF NOT EXISTS a ON b (c) PARTITION BY LIST (d) (PARTITION e VALUES IN (1)) +CREATE INDEX IF NOT EXISTS a ON b (c) PARTITION BY LIST (d) (PARTITION e VALUES IN ((1))) -- fully parenthetized +CREATE INDEX IF NOT EXISTS a ON b (c) PARTITION BY LIST (d) (PARTITION e VALUES IN (_)) -- literals removed +CREATE INDEX IF NOT EXISTS _ ON _ (_) PARTITION BY LIST (_) (PARTITION _ VALUES IN (1)) -- identifiers removed + +parse +ALTER TABLE a PARTITION BY LIST (b) (PARTITION p1 VALUES IN (1)) +---- +ALTER TABLE a PARTITION BY LIST (b) (PARTITION p1 VALUES IN (1)) +ALTER TABLE a PARTITION BY LIST (b) (PARTITION p1 VALUES IN ((1))) -- fully parenthetized +ALTER TABLE a PARTITION BY LIST (b) (PARTITION p1 VALUES IN (_)) -- literals removed +ALTER TABLE _ PARTITION BY LIST (_) (PARTITION _ VALUES IN (1)) -- identifiers removed + +parse +ALTER TABLE a PARTITION ALL BY LIST (b) (PARTITION p1 VALUES IN (1)) +---- +ALTER TABLE a PARTITION ALL BY LIST (b) (PARTITION p1 VALUES IN (1)) +ALTER TABLE a PARTITION ALL BY LIST (b) (PARTITION p1 VALUES IN ((1))) -- fully parenthetized +ALTER TABLE a PARTITION ALL BY LIST (b) (PARTITION p1 VALUES IN (_)) -- literals removed +ALTER TABLE _ PARTITION ALL BY LIST (_) (PARTITION _ VALUES IN (1)) -- identifiers removed + +parse +ALTER INDEX a@idx PARTITION BY LIST (b) (PARTITION p1 VALUES IN (1)) +---- +ALTER INDEX a@idx PARTITION BY LIST (b) (PARTITION p1 VALUES IN (1)) +ALTER INDEX a@idx PARTITION BY LIST (b) (PARTITION p1 VALUES IN ((1))) -- fully parenthetized +ALTER INDEX a@idx PARTITION BY LIST (b) (PARTITION p1 VALUES IN (_)) -- literals removed +ALTER INDEX _@_ PARTITION BY LIST (_) (PARTITION _ VALUES IN (1)) -- identifiers removed + +parse +CREATE TABLE a AS SELECT * FROM b +---- +CREATE TABLE a AS SELECT * FROM b +CREATE TABLE a AS SELECT (*) FROM b -- fully parenthetized +CREATE TABLE a AS SELECT * FROM b -- literals removed +CREATE TABLE _ AS SELECT * FROM _ -- identifiers removed + +parse +CREATE TABLE IF NOT EXISTS a AS SELECT * FROM b +---- +CREATE TABLE IF NOT EXISTS a AS SELECT * FROM b +CREATE TABLE IF NOT EXISTS a AS SELECT (*) FROM b -- fully parenthetized +CREATE TABLE IF NOT EXISTS a AS SELECT * FROM b -- literals removed +CREATE TABLE IF NOT EXISTS _ AS SELECT * FROM _ -- identifiers removed + +parse +CREATE TABLE a AS SELECT * FROM b ORDER BY c +---- +CREATE TABLE a AS SELECT * FROM b ORDER BY c +CREATE TABLE a AS SELECT (*) FROM b ORDER BY (c) -- fully parenthetized +CREATE TABLE a AS SELECT * FROM b ORDER BY c -- literals removed +CREATE TABLE _ AS SELECT * FROM _ ORDER BY _ -- identifiers removed + +parse +CREATE TABLE IF NOT EXISTS a AS SELECT * FROM b ORDER BY c +---- +CREATE TABLE IF NOT EXISTS a AS SELECT * FROM b ORDER BY c +CREATE TABLE IF NOT EXISTS a AS SELECT (*) FROM b ORDER BY (c) -- fully parenthetized +CREATE TABLE IF NOT EXISTS a AS SELECT * FROM b ORDER BY c -- literals removed +CREATE TABLE IF NOT EXISTS _ AS SELECT * FROM _ ORDER BY _ -- identifiers removed + +parse +CREATE TABLE a AS SELECT * FROM b LIMIT 3 +---- +CREATE TABLE a AS SELECT * FROM b LIMIT 3 +CREATE TABLE a AS SELECT (*) FROM b LIMIT (3) -- fully parenthetized +CREATE TABLE a AS SELECT * FROM b LIMIT _ -- literals removed +CREATE TABLE _ AS SELECT * FROM _ LIMIT 3 -- identifiers removed + +parse +CREATE TABLE IF NOT EXISTS a AS SELECT * FROM b LIMIT 3 +---- +CREATE TABLE IF NOT EXISTS a AS SELECT * FROM b LIMIT 3 +CREATE TABLE IF NOT EXISTS a AS SELECT (*) FROM b LIMIT (3) -- fully parenthetized +CREATE TABLE IF NOT EXISTS a AS SELECT * FROM b LIMIT _ -- literals removed +CREATE TABLE IF NOT EXISTS _ AS SELECT * FROM _ LIMIT 3 -- identifiers removed + +parse +CREATE TABLE a AS VALUES ('one', 1), ('two', 2), ('three', 3) +---- +CREATE TABLE a AS VALUES ('one', 1), ('two', 2), ('three', 3) +CREATE TABLE a AS VALUES (('one'), (1)), (('two'), (2)), (('three'), (3)) -- fully parenthetized +CREATE TABLE a AS VALUES (_, _), (__more2__) -- literals removed +CREATE TABLE _ AS VALUES ('one', 1), ('two', 2), ('three', 3) -- identifiers removed + +parse +CREATE TABLE IF NOT EXISTS 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 IF NOT EXISTS a AS VALUES (('one'), (1)), (('two'), (2)), (('three'), (3)) -- fully parenthetized +CREATE TABLE IF NOT EXISTS a AS VALUES (_, _), (__more2__) -- literals removed +CREATE TABLE IF NOT EXISTS _ AS VALUES ('one', 1), ('two', 2), ('three', 3) -- identifiers removed + +parse +CREATE TABLE a (str, num) AS VALUES ('one', 1), ('two', 2), ('three', 3) +---- +CREATE TABLE a (str, num) AS VALUES ('one', 1), ('two', 2), ('three', 3) +CREATE TABLE a (str, num) AS VALUES (('one'), (1)), (('two'), (2)), (('three'), (3)) -- fully parenthetized +CREATE TABLE a (str, num) AS VALUES (_, _), (__more2__) -- literals removed +CREATE TABLE _ (_, _) AS VALUES ('one', 1), ('two', 2), ('three', 3) -- identifiers removed + +parse +CREATE TABLE IF NOT EXISTS 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 IF NOT EXISTS a (str, num) AS VALUES (('one'), (1)), (('two'), (2)), (('three'), (3)) -- fully parenthetized +CREATE TABLE IF NOT EXISTS a (str, num) AS VALUES (_, _), (__more2__) -- literals removed +CREATE TABLE IF NOT EXISTS _ (_, _) AS VALUES ('one', 1), ('two', 2), ('three', 3) -- identifiers removed + +parse +CREATE TABLE a AS SELECT * FROM b UNION SELECT * FROM c +---- +CREATE TABLE a AS SELECT * FROM b UNION SELECT * FROM c +CREATE TABLE a AS SELECT (*) FROM b UNION SELECT (*) FROM c -- fully parenthetized +CREATE TABLE a AS SELECT * FROM b UNION SELECT * FROM c -- literals removed +CREATE TABLE _ AS SELECT * FROM _ UNION SELECT * FROM _ -- identifiers removed + +parse +CREATE TABLE IF NOT EXISTS 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 IF NOT EXISTS a AS SELECT (*) FROM b UNION SELECT (*) FROM c -- fully parenthetized +CREATE TABLE IF NOT EXISTS a AS SELECT * FROM b UNION SELECT * FROM c -- literals removed +CREATE TABLE IF NOT EXISTS _ AS SELECT * FROM _ UNION SELECT * FROM _ -- identifiers removed + +parse +CREATE TABLE a AS SELECT * FROM b UNION VALUES ('one', 1) ORDER BY c LIMIT 5 +---- +CREATE TABLE a AS SELECT * FROM b UNION VALUES ('one', 1) ORDER BY c LIMIT 5 +CREATE TABLE a AS SELECT (*) FROM b UNION VALUES (('one'), (1)) ORDER BY (c) LIMIT (5) -- fully parenthetized +CREATE TABLE a AS SELECT * FROM b UNION VALUES (_, _) ORDER BY c LIMIT _ -- literals removed +CREATE TABLE _ AS SELECT * FROM _ UNION VALUES ('one', 1) ORDER BY _ LIMIT 5 -- identifiers removed + +parse +CREATE TABLE IF NOT EXISTS 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 IF NOT EXISTS a AS SELECT (*) FROM b UNION VALUES (('one'), (1)) ORDER BY (c) LIMIT (5) -- fully parenthetized +CREATE TABLE IF NOT EXISTS a AS SELECT * FROM b UNION VALUES (_, _) ORDER BY c LIMIT _ -- literals removed +CREATE TABLE IF NOT EXISTS _ AS SELECT * FROM _ UNION VALUES ('one', 1) ORDER BY _ LIMIT 5 -- identifiers removed + +parse +CREATE TABLE a (z PRIMARY KEY) AS SELECT * FROM b +---- +CREATE TABLE a (z PRIMARY KEY) AS SELECT * FROM b +CREATE TABLE a (z PRIMARY KEY) AS SELECT (*) FROM b -- fully parenthetized +CREATE TABLE a (z PRIMARY KEY) AS SELECT * FROM b -- literals removed +CREATE TABLE _ (_ PRIMARY KEY) AS SELECT * FROM _ -- identifiers removed + +parse +CREATE TABLE IF NOT EXISTS a (z PRIMARY KEY) AS SELECT * FROM b +---- +CREATE TABLE IF NOT EXISTS a (z PRIMARY KEY) AS SELECT * FROM b +CREATE TABLE IF NOT EXISTS a (z PRIMARY KEY) AS SELECT (*) FROM b -- fully parenthetized +CREATE TABLE IF NOT EXISTS a (z PRIMARY KEY) AS SELECT * FROM b -- literals removed +CREATE TABLE IF NOT EXISTS _ (_ PRIMARY KEY) AS SELECT * FROM _ -- identifiers removed + +parse +CREATE TABLE a (x, y, z, PRIMARY KEY (x, y, z)) AS SELECT * FROM b +---- +CREATE TABLE a (x, y, z, PRIMARY KEY (x, y, z)) AS SELECT * FROM b +CREATE TABLE a (x, y, z, PRIMARY KEY (x, y, z)) AS SELECT (*) FROM b -- fully parenthetized +CREATE TABLE a (x, y, z, PRIMARY KEY (x, y, z)) AS SELECT * FROM b -- literals removed +CREATE TABLE _ (_, _, _, PRIMARY KEY (_, _, _)) AS SELECT * FROM _ -- identifiers removed + +parse +CREATE TABLE IF NOT EXISTS 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 IF NOT EXISTS a (x, y, z, PRIMARY KEY (x, y, z)) AS SELECT (*) FROM b -- fully parenthetized +CREATE TABLE IF NOT EXISTS a (x, y, z, PRIMARY KEY (x, y, z)) AS SELECT * FROM b -- literals removed +CREATE TABLE IF NOT EXISTS _ (_, _, _, PRIMARY KEY (_, _, _)) AS SELECT * FROM _ -- identifiers removed + +parse +CREATE TABLE a (x, FAMILY (x)) AS SELECT * FROM b +---- +CREATE TABLE a (x, FAMILY (x)) AS SELECT * FROM b +CREATE TABLE a (x, FAMILY (x)) AS SELECT (*) FROM b -- fully parenthetized +CREATE TABLE a (x, FAMILY (x)) AS SELECT * FROM b -- literals removed +CREATE TABLE _ (_, FAMILY (_)) AS SELECT * FROM _ -- identifiers removed + +parse +CREATE TABLE IF NOT EXISTS a (x, FAMILY (x)) AS SELECT * FROM b +---- +CREATE TABLE IF NOT EXISTS a (x, FAMILY (x)) AS SELECT * FROM b +CREATE TABLE IF NOT EXISTS a (x, FAMILY (x)) AS SELECT (*) FROM b -- fully parenthetized +CREATE TABLE IF NOT EXISTS a (x, FAMILY (x)) AS SELECT * FROM b -- literals removed +CREATE TABLE IF NOT EXISTS _ (_, FAMILY (_)) AS SELECT * FROM _ -- identifiers removed + +parse +CREATE TABLE a (x, y FAMILY f1) AS SELECT * FROM b +---- +CREATE TABLE a (x, y FAMILY f1) AS SELECT * FROM b +CREATE TABLE a (x, y FAMILY f1) AS SELECT (*) FROM b -- fully parenthetized +CREATE TABLE a (x, y FAMILY f1) AS SELECT * FROM b -- literals removed +CREATE TABLE _ (_, _ FAMILY _) AS SELECT * FROM _ -- identifiers removed + +parse +CREATE TABLE IF NOT EXISTS 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 IF NOT EXISTS a (x, y FAMILY f1) AS SELECT (*) FROM b -- fully parenthetized +CREATE TABLE IF NOT EXISTS a (x, y FAMILY f1) AS SELECT * FROM b -- literals removed +CREATE TABLE IF NOT EXISTS _ (_, _ FAMILY _) AS SELECT * FROM _ -- identifiers removed + +parse +CREATE TABLE a (b STRING COLLATE de) +---- +CREATE TABLE a (b STRING COLLATE de) +CREATE TABLE a (b STRING COLLATE de) -- fully parenthetized +CREATE TABLE a (b STRING COLLATE de) -- literals removed +CREATE TABLE _ (_ STRING COLLATE de) -- identifiers removed + +parse +CREATE TABLE a (b STRING COLLATE "en-us") +---- +CREATE TABLE a (b STRING COLLATE en_US) -- normalized! +CREATE TABLE a (b STRING COLLATE en_US) -- fully parenthetized +CREATE TABLE a (b STRING COLLATE en_US) -- literals removed +CREATE TABLE _ (_ STRING COLLATE en_US) -- identifiers removed + +parse +CREATE TABLE a (b STRING COLLATE en_us) +---- +CREATE TABLE a (b STRING COLLATE en_US) -- normalized! +CREATE TABLE a (b STRING COLLATE en_US) -- fully parenthetized +CREATE TABLE a (b STRING COLLATE en_US) -- literals removed +CREATE TABLE _ (_ STRING COLLATE en_US) -- identifiers removed + +parse +CREATE TABLE a (b STRING(3) COLLATE de) +---- +CREATE TABLE a (b STRING(3) COLLATE de) +CREATE TABLE a (b STRING(3) COLLATE de) -- fully parenthetized +CREATE TABLE a (b STRING(3) COLLATE de) -- literals removed +CREATE TABLE _ (_ STRING(3) COLLATE de) -- identifiers removed + +parse +CREATE TABLE a (b STRING[] COLLATE de) +---- +CREATE TABLE a (b STRING[] COLLATE de) +CREATE TABLE a (b STRING[] COLLATE de) -- fully parenthetized +CREATE TABLE a (b STRING[] COLLATE de) -- literals removed +CREATE TABLE _ (_ STRING[] COLLATE de) -- identifiers removed + +parse +CREATE TABLE a (b STRING(3)[] COLLATE en_US) +---- +CREATE TABLE a (b STRING(3)[] COLLATE en_US) +CREATE TABLE a (b STRING(3)[] COLLATE en_US) -- fully parenthetized +CREATE TABLE a (b STRING(3)[] COLLATE en_US) -- literals removed +CREATE TABLE _ (_ STRING(3)[] COLLATE en_US) -- identifiers removed + +parse +CREATE TABLE a (LIKE b) +---- +CREATE TABLE a (LIKE b) +CREATE TABLE a (LIKE b) -- fully parenthetized +CREATE TABLE a (LIKE b) -- literals removed +CREATE TABLE _ (LIKE _) -- identifiers removed + +parse +CREATE TABLE a (LIKE b, c INT8) +---- +CREATE TABLE a (LIKE b, c INT8) +CREATE TABLE a (LIKE b, c INT8) -- fully parenthetized +CREATE TABLE a (LIKE b, c INT8) -- literals removed +CREATE TABLE _ (LIKE _, _ INT8) -- identifiers removed + +parse +CREATE TABLE a (LIKE b EXCLUDING INDEXES INCLUDING INDEXES) +---- +CREATE TABLE a (LIKE b EXCLUDING INDEXES INCLUDING INDEXES) +CREATE TABLE a (LIKE b EXCLUDING INDEXES INCLUDING INDEXES) -- fully parenthetized +CREATE TABLE a (LIKE b EXCLUDING INDEXES INCLUDING INDEXES) -- literals removed +CREATE TABLE _ (LIKE _ EXCLUDING INDEXES INCLUDING INDEXES) -- identifiers removed + +parse +CREATE TABLE a (LIKE b INCLUDING ALL EXCLUDING INDEXES, c INT8) +---- +CREATE TABLE a (LIKE b INCLUDING ALL EXCLUDING INDEXES, c INT8) +CREATE TABLE a (LIKE b INCLUDING ALL EXCLUDING INDEXES, c INT8) -- fully parenthetized +CREATE TABLE a (LIKE b INCLUDING ALL EXCLUDING INDEXES, c INT8) -- literals removed +CREATE TABLE _ (LIKE _ INCLUDING ALL EXCLUDING INDEXES, _ INT8) -- identifiers removed + +parse +CREATE TABLE a (a INT4) LOCALITY GLOBAL +---- +CREATE TABLE a (a INT4) LOCALITY GLOBAL +CREATE TABLE a (a INT4) LOCALITY GLOBAL -- fully parenthetized +CREATE TABLE a (a INT4) LOCALITY GLOBAL -- literals removed +CREATE TABLE _ (_ INT4) LOCALITY GLOBAL -- identifiers removed + +parse +CREATE TABLE a (a INT4) LOCALITY REGIONAL BY TABLE IN "us-west1" +---- +CREATE TABLE a (a INT4) LOCALITY REGIONAL BY TABLE IN "us-west1" +CREATE TABLE a (a INT4) LOCALITY REGIONAL BY TABLE IN "us-west1" -- fully parenthetized +CREATE TABLE a (a INT4) LOCALITY REGIONAL BY TABLE IN "us-west1" -- literals removed +CREATE TABLE _ (_ INT4) LOCALITY REGIONAL BY TABLE IN _ -- identifiers removed + +parse +CREATE TABLE a (a INT4) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION +---- +CREATE TABLE a (a INT4) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION +CREATE TABLE a (a INT4) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- fully parenthetized +CREATE TABLE a (a INT4) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- literals removed +CREATE TABLE _ (_ INT4) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- identifiers removed + + +parse +CREATE TABLE a (a INT4) LOCALITY REGIONAL BY TABLE +---- +CREATE TABLE a (a INT4) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- normalized! +CREATE TABLE a (a INT4) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- fully parenthetized +CREATE TABLE a (a INT4) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- literals removed +CREATE TABLE _ (_ INT4) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION -- identifiers removed + + +parse +CREATE TABLE a (a INT4) LOCALITY REGIONAL BY ROW +---- +CREATE TABLE a (a INT4) LOCALITY REGIONAL BY ROW +CREATE TABLE a (a INT4) LOCALITY REGIONAL BY ROW -- fully parenthetized +CREATE TABLE a (a INT4) LOCALITY REGIONAL BY ROW -- literals removed +CREATE TABLE _ (_ INT4) LOCALITY REGIONAL BY ROW -- identifiers removed + +parse +CREATE TABLE a (a INT4) LOCALITY REGIONAL BY ROW AS bobby +---- +CREATE TABLE a (a INT4) LOCALITY REGIONAL BY ROW AS bobby +CREATE TABLE a (a INT4) LOCALITY REGIONAL BY ROW AS bobby -- fully parenthetized +CREATE TABLE a (a INT4) LOCALITY REGIONAL BY ROW AS bobby -- literals removed +CREATE TABLE _ (_ INT4) LOCALITY REGIONAL BY ROW AS _ -- identifiers removed + +parse +CREATE TABLE a (b INT) WITH (fillfactor=100) +---- +CREATE TABLE a (b INT8) -- normalized! +CREATE TABLE a (b INT8) -- fully parenthetized +CREATE TABLE a (b INT8) -- literals removed +CREATE TABLE _ (_ INT8) -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/create_type b/pkg/sql/parser/testdata/parse/create_type new file mode 100644 index 000000000000..d0758c185b9d --- /dev/null +++ b/pkg/sql/parser/testdata/parse/create_type @@ -0,0 +1,47 @@ +parse +CREATE TYPE a AS ENUM () +---- +CREATE TYPE a AS ENUM () +CREATE TYPE a AS ENUM () -- fully parenthetized +CREATE TYPE a AS ENUM () -- literals removed +CREATE TYPE _ AS ENUM () -- identifiers removed + +parse +CREATE TYPE IF NOT EXISTS a AS ENUM () +---- +CREATE TYPE IF NOT EXISTS a AS ENUM () +CREATE TYPE IF NOT EXISTS a AS ENUM () -- fully parenthetized +CREATE TYPE IF NOT EXISTS a AS ENUM () -- literals removed +CREATE TYPE IF NOT EXISTS _ AS ENUM () -- identifiers removed + +parse +CREATE TYPE a AS ENUM ('a') +---- +CREATE TYPE a AS ENUM ('a') +CREATE TYPE a AS ENUM ('a') -- fully parenthetized +CREATE TYPE a AS ENUM ('a') -- literals removed +CREATE TYPE _ AS ENUM (_) -- identifiers removed + +parse +CREATE TYPE a AS ENUM ('a', 'b', 'c') +---- +CREATE TYPE a AS ENUM ('a', 'b', 'c') +CREATE TYPE a AS ENUM ('a', 'b', 'c') -- fully parenthetized +CREATE TYPE a AS ENUM ('a', 'b', 'c') -- literals removed +CREATE TYPE _ AS ENUM (_, _, _) -- identifiers removed + +parse +CREATE TYPE a.b AS ENUM ('a', 'b', 'c') +---- +CREATE TYPE a.b AS ENUM ('a', 'b', 'c') +CREATE TYPE a.b AS ENUM ('a', 'b', 'c') -- fully parenthetized +CREATE TYPE a.b AS ENUM ('a', 'b', 'c') -- literals removed +CREATE TYPE _._ AS ENUM (_, _, _) -- identifiers removed + +parse +CREATE TYPE a.b.c AS ENUM ('a', 'b', 'c') +---- +CREATE TYPE a.b.c AS ENUM ('a', 'b', 'c') +CREATE TYPE a.b.c AS ENUM ('a', 'b', 'c') -- fully parenthetized +CREATE TYPE a.b.c AS ENUM ('a', 'b', 'c') -- literals removed +CREATE TYPE _._._ AS ENUM (_, _, _) -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/create_user b/pkg/sql/parser/testdata/parse/create_user new file mode 100644 index 000000000000..d31355ac9c3f --- /dev/null +++ b/pkg/sql/parser/testdata/parse/create_user @@ -0,0 +1,145 @@ +parse +CREATE USER foo +---- +CREATE USER 'foo' -- normalized! +CREATE USER ('foo') -- fully parenthetized +CREATE USER _ -- literals removed +CREATE USER '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +CREATE USER 'foo' -- identifiers removed + +parse +CREATE USER IF NOT EXISTS foo +---- +CREATE USER IF NOT EXISTS 'foo' -- normalized! +CREATE USER IF NOT EXISTS ('foo') -- fully parenthetized +CREATE USER IF NOT EXISTS _ -- literals removed +CREATE USER IF NOT EXISTS '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +CREATE USER IF NOT EXISTS 'foo' -- identifiers removed + + +parse +CREATE ROLE foo +---- +CREATE ROLE 'foo' -- normalized! +CREATE ROLE ('foo') -- fully parenthetized +CREATE ROLE _ -- literals removed +CREATE ROLE '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +CREATE ROLE 'foo' -- identifiers removed + +parse +CREATE ROLE IF NOT EXISTS foo +---- +CREATE ROLE IF NOT EXISTS 'foo' -- normalized! +CREATE ROLE IF NOT EXISTS ('foo') -- fully parenthetized +CREATE ROLE IF NOT EXISTS _ -- literals removed +CREATE ROLE IF NOT EXISTS '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +CREATE ROLE IF NOT EXISTS 'foo' -- identifiers removed + +parse +CREATE ROLE foo WITH CREATEDB +---- +CREATE ROLE 'foo' WITH CREATEDB -- normalized! +CREATE ROLE ('foo') WITH CREATEDB -- fully parenthetized +CREATE ROLE _ WITH CREATEDB -- literals removed +CREATE ROLE '_' WITH CREATEDB -- UNEXPECTED REPARSED AST WITHOUT LITERALS +CREATE ROLE 'foo' WITH CREATEDB -- identifiers removed + +parse +CREATE ROLE IF NOT EXISTS foo WITH CREATEDB +---- +CREATE ROLE IF NOT EXISTS 'foo' WITH CREATEDB -- normalized! +CREATE ROLE IF NOT EXISTS ('foo') WITH CREATEDB -- fully parenthetized +CREATE ROLE IF NOT EXISTS _ WITH CREATEDB -- literals removed +CREATE ROLE IF NOT EXISTS '_' WITH CREATEDB -- UNEXPECTED REPARSED AST WITHOUT LITERALS +CREATE ROLE IF NOT EXISTS 'foo' WITH CREATEDB -- identifiers removed + +parse +CREATE ROLE foo CREATEDB +---- +CREATE ROLE 'foo' WITH CREATEDB -- normalized! +CREATE ROLE ('foo') WITH CREATEDB -- fully parenthetized +CREATE ROLE _ WITH CREATEDB -- literals removed +CREATE ROLE '_' WITH CREATEDB -- UNEXPECTED REPARSED AST WITHOUT LITERALS +CREATE ROLE 'foo' WITH CREATEDB -- identifiers removed + +parse +CREATE ROLE IF NOT EXISTS foo CREATEDB +---- +CREATE ROLE IF NOT EXISTS 'foo' WITH CREATEDB -- normalized! +CREATE ROLE IF NOT EXISTS ('foo') WITH CREATEDB -- fully parenthetized +CREATE ROLE IF NOT EXISTS _ WITH CREATEDB -- literals removed +CREATE ROLE IF NOT EXISTS '_' WITH CREATEDB -- UNEXPECTED REPARSED AST WITHOUT LITERALS +CREATE ROLE IF NOT EXISTS 'foo' WITH CREATEDB -- identifiers removed + +parse +CREATE ROLE foo WITH CREATEROLE +---- +CREATE ROLE 'foo' WITH CREATEROLE -- normalized! +CREATE ROLE ('foo') WITH CREATEROLE -- fully parenthetized +CREATE ROLE _ WITH CREATEROLE -- literals removed +CREATE ROLE '_' WITH CREATEROLE -- UNEXPECTED REPARSED AST WITHOUT LITERALS +CREATE ROLE 'foo' WITH CREATEROLE -- identifiers removed + +parse +CREATE ROLE IF NOT EXISTS foo WITH CREATEROLE +---- +CREATE ROLE IF NOT EXISTS 'foo' WITH CREATEROLE -- normalized! +CREATE ROLE IF NOT EXISTS ('foo') WITH CREATEROLE -- fully parenthetized +CREATE ROLE IF NOT EXISTS _ WITH CREATEROLE -- literals removed +CREATE ROLE IF NOT EXISTS '_' WITH CREATEROLE -- UNEXPECTED REPARSED AST WITHOUT LITERALS +CREATE ROLE IF NOT EXISTS 'foo' WITH CREATEROLE -- identifiers removed + +parse +CREATE ROLE foo CREATEROLE +---- +CREATE ROLE 'foo' WITH CREATEROLE -- normalized! +CREATE ROLE ('foo') WITH CREATEROLE -- fully parenthetized +CREATE ROLE _ WITH CREATEROLE -- literals removed +CREATE ROLE '_' WITH CREATEROLE -- UNEXPECTED REPARSED AST WITHOUT LITERALS +CREATE ROLE 'foo' WITH CREATEROLE -- identifiers removed + +parse +CREATE ROLE IF NOT EXISTS foo CREATEROLE +---- +CREATE ROLE IF NOT EXISTS 'foo' WITH CREATEROLE -- normalized! +CREATE ROLE IF NOT EXISTS ('foo') WITH CREATEROLE -- fully parenthetized +CREATE ROLE IF NOT EXISTS _ WITH CREATEROLE -- literals removed +CREATE ROLE IF NOT EXISTS '_' WITH CREATEROLE -- UNEXPECTED REPARSED AST WITHOUT LITERALS +CREATE ROLE IF NOT EXISTS 'foo' WITH CREATEROLE -- identifiers removed + +parse +CREATE USER foo PASSWORD bar +---- +CREATE USER 'foo' WITH PASSWORD '*****' -- normalized! +CREATE USER ('foo') WITH PASSWORD '*****' -- fully parenthetized +CREATE USER _ WITH PASSWORD '*****' -- literals removed +CREATE USER '_' WITH PASSWORD '*****' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +CREATE USER 'foo' WITH PASSWORD '*****' -- identifiers removed +CREATE USER 'foo' WITH PASSWORD 'bar' -- passwords exposed + +parse +CREATE USER foo PASSWORD NULL +---- +CREATE USER 'foo' WITH PASSWORD NULL -- normalized! +CREATE USER ('foo') WITH PASSWORD (NULL) -- fully parenthetized +CREATE USER _ WITH PASSWORD _ -- literals removed +CREATE USER '_' WITH PASSWORD '*****' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +CREATE USER 'foo' WITH PASSWORD NULL -- identifiers removed + +parse +CREATE USER foo LOGIN VALID UNTIL NULL PASSWORD NULL +---- +CREATE USER 'foo' WITH LOGIN VALID UNTIL NULL PASSWORD NULL -- normalized! +CREATE USER ('foo') WITH LOGIN VALID UNTIL (NULL) PASSWORD (NULL) -- fully parenthetized +CREATE USER _ WITH LOGIN VALID UNTIL _ PASSWORD _ -- literals removed +CREATE USER '_' WITH LOGIN VALID UNTIL '_' PASSWORD '*****' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +CREATE USER 'foo' WITH LOGIN VALID UNTIL NULL PASSWORD NULL -- identifiers removed + +parse +CREATE USER foo VALID UNTIL '1970-01-01' +---- +CREATE USER 'foo' WITH VALID UNTIL '1970-01-01' -- normalized! +CREATE USER ('foo') WITH VALID UNTIL ('1970-01-01') -- fully parenthetized +CREATE USER _ WITH VALID UNTIL _ -- literals removed +CREATE USER '_' WITH VALID UNTIL '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +CREATE USER 'foo' WITH VALID UNTIL '1970-01-01' -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/create_view b/pkg/sql/parser/testdata/parse/create_view new file mode 100644 index 000000000000..807eb97f9f7d --- /dev/null +++ b/pkg/sql/parser/testdata/parse/create_view @@ -0,0 +1,127 @@ +parse +CREATE VIEW a AS SELECT * FROM b +---- +CREATE VIEW a AS SELECT * FROM b +CREATE VIEW a AS SELECT (*) FROM b -- fully parenthetized +CREATE VIEW a AS SELECT * FROM b -- literals removed +CREATE VIEW _ AS SELECT * FROM _ -- identifiers removed + +parse +CREATE OR REPLACE VIEW a AS SELECT * FROM b +---- +CREATE OR REPLACE VIEW a AS SELECT * FROM b +CREATE OR REPLACE VIEW a AS SELECT (*) FROM b -- fully parenthetized +CREATE OR REPLACE VIEW a AS SELECT * FROM b -- literals removed +CREATE OR REPLACE VIEW _ AS SELECT * FROM _ -- identifiers removed + +parse +EXPLAIN CREATE VIEW a AS SELECT * FROM b +---- +EXPLAIN CREATE VIEW a AS SELECT * FROM b +EXPLAIN CREATE VIEW a AS SELECT (*) FROM b -- fully parenthetized +EXPLAIN CREATE VIEW a AS SELECT * FROM b -- literals removed +EXPLAIN CREATE VIEW _ AS SELECT * FROM _ -- identifiers removed + +parse +CREATE VIEW a AS SELECT b.* FROM b LIMIT 5 +---- +CREATE VIEW a AS SELECT b.* FROM b LIMIT 5 +CREATE VIEW a AS SELECT (b.*) FROM b LIMIT (5) -- fully parenthetized +CREATE VIEW a AS SELECT b.* FROM b LIMIT _ -- literals removed +CREATE VIEW _ AS SELECT _.* FROM _ LIMIT 5 -- identifiers removed + +parse +CREATE VIEW a AS (SELECT c, d FROM b WHERE c > 0 ORDER BY c) +---- +CREATE VIEW a AS (SELECT c, d FROM b WHERE c > 0 ORDER BY c) +CREATE VIEW a AS (SELECT (c), (d) FROM b WHERE ((c) > (0)) ORDER BY (c)) -- fully parenthetized +CREATE VIEW a AS (SELECT c, d FROM b WHERE c > _ ORDER BY c) -- literals removed +CREATE VIEW _ AS (SELECT _, _ FROM _ WHERE _ > 0 ORDER BY _) -- identifiers removed + +parse +CREATE VIEW a (x, y) AS SELECT c, d FROM b +---- +CREATE VIEW a (x, y) AS SELECT c, d FROM b +CREATE VIEW a (x, y) AS SELECT (c), (d) FROM b -- fully parenthetized +CREATE VIEW a (x, y) AS SELECT c, d FROM b -- literals removed +CREATE VIEW _ (_, _) AS SELECT _, _ FROM _ -- identifiers removed + +parse +CREATE VIEW a AS VALUES (1, 'one'), (2, 'two') +---- +CREATE VIEW a AS VALUES (1, 'one'), (2, 'two') +CREATE VIEW a AS VALUES ((1), ('one')), ((2), ('two')) -- fully parenthetized +CREATE VIEW a AS VALUES (_, _), (__more1__) -- literals removed +CREATE VIEW _ AS VALUES (1, 'one'), (2, 'two') -- identifiers removed + +parse +CREATE VIEW a (x, y) AS VALUES (1, 'one'), (2, 'two') +---- +CREATE VIEW a (x, y) AS VALUES (1, 'one'), (2, 'two') +CREATE VIEW a (x, y) AS VALUES ((1), ('one')), ((2), ('two')) -- fully parenthetized +CREATE VIEW a (x, y) AS VALUES (_, _), (__more1__) -- literals removed +CREATE VIEW _ (_, _) AS VALUES (1, 'one'), (2, 'two') -- identifiers removed + +parse +CREATE VIEW a AS TABLE b +---- +CREATE VIEW a AS TABLE b +CREATE VIEW a AS TABLE b -- fully parenthetized +CREATE VIEW a AS TABLE b -- literals removed +CREATE VIEW _ AS TABLE _ -- identifiers removed + +parse +CREATE TEMPORARY VIEW a AS SELECT b +---- +CREATE TEMPORARY VIEW a AS SELECT b +CREATE TEMPORARY VIEW a AS SELECT (b) -- fully parenthetized +CREATE TEMPORARY VIEW a AS SELECT b -- literals removed +CREATE TEMPORARY VIEW _ AS SELECT _ -- identifiers removed + +parse +CREATE MATERIALIZED VIEW a AS SELECT * FROM b +---- +CREATE MATERIALIZED VIEW a AS SELECT * FROM b +CREATE MATERIALIZED VIEW a AS SELECT (*) FROM b -- fully parenthetized +CREATE MATERIALIZED VIEW a AS SELECT * FROM b -- literals removed +CREATE MATERIALIZED VIEW _ AS SELECT * FROM _ -- identifiers removed + +parse +CREATE MATERIALIZED VIEW IF NOT EXISTS a AS SELECT * FROM b +---- +CREATE MATERIALIZED VIEW IF NOT EXISTS a AS SELECT * FROM b +CREATE MATERIALIZED VIEW IF NOT EXISTS a AS SELECT (*) FROM b -- fully parenthetized +CREATE MATERIALIZED VIEW IF NOT EXISTS a AS SELECT * FROM b -- literals removed +CREATE MATERIALIZED VIEW IF NOT EXISTS _ AS SELECT * FROM _ -- identifiers removed + +parse +REFRESH MATERIALIZED VIEW a.b +---- +REFRESH MATERIALIZED VIEW a.b +REFRESH MATERIALIZED VIEW a.b -- fully parenthetized +REFRESH MATERIALIZED VIEW a.b -- literals removed +REFRESH MATERIALIZED VIEW _._ -- identifiers removed + +parse +REFRESH MATERIALIZED VIEW CONCURRENTLY a.b +---- +REFRESH MATERIALIZED VIEW CONCURRENTLY a.b +REFRESH MATERIALIZED VIEW CONCURRENTLY a.b -- fully parenthetized +REFRESH MATERIALIZED VIEW CONCURRENTLY a.b -- literals removed +REFRESH MATERIALIZED VIEW CONCURRENTLY _._ -- identifiers removed + +parse +REFRESH MATERIALIZED VIEW a.b WITH DATA +---- +REFRESH MATERIALIZED VIEW a.b WITH DATA +REFRESH MATERIALIZED VIEW a.b WITH DATA -- fully parenthetized +REFRESH MATERIALIZED VIEW a.b WITH DATA -- literals removed +REFRESH MATERIALIZED VIEW _._ WITH DATA -- identifiers removed + +parse +REFRESH MATERIALIZED VIEW a.b WITH NO DATA +---- +REFRESH MATERIALIZED VIEW a.b WITH NO DATA +REFRESH MATERIALIZED VIEW a.b WITH NO DATA -- fully parenthetized +REFRESH MATERIALIZED VIEW a.b WITH NO DATA -- literals removed +REFRESH MATERIALIZED VIEW _._ WITH NO DATA -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/delete b/pkg/sql/parser/testdata/parse/delete new file mode 100644 index 000000000000..fab658a94eea --- /dev/null +++ b/pkg/sql/parser/testdata/parse/delete @@ -0,0 +1,127 @@ +parse +DELETE FROM a +---- +DELETE FROM a +DELETE FROM a -- fully parenthetized +DELETE FROM a -- literals removed +DELETE FROM _ -- identifiers removed + +parse +EXPLAIN DELETE FROM a +---- +EXPLAIN DELETE FROM a +EXPLAIN DELETE FROM a -- fully parenthetized +EXPLAIN DELETE FROM a -- literals removed +EXPLAIN DELETE FROM _ -- identifiers removed + +parse +DELETE FROM a.b +---- +DELETE FROM a.b +DELETE FROM a.b -- fully parenthetized +DELETE FROM a.b -- literals removed +DELETE FROM _._ -- identifiers removed + +parse +DELETE FROM a.b@c +---- +DELETE FROM a.b@c +DELETE FROM a.b@c -- fully parenthetized +DELETE FROM a.b@c -- literals removed +DELETE FROM _._@_ -- identifiers removed + +parse +DELETE FROM a WHERE a = b +---- +DELETE FROM a WHERE a = b +DELETE FROM a WHERE ((a) = (b)) -- fully parenthetized +DELETE FROM a WHERE a = b -- literals removed +DELETE FROM _ WHERE _ = _ -- identifiers removed + +parse +DELETE FROM a WHERE a = b LIMIT c +---- +DELETE FROM a WHERE a = b LIMIT c +DELETE FROM a WHERE ((a) = (b)) LIMIT (c) -- fully parenthetized +DELETE FROM a WHERE a = b LIMIT c -- literals removed +DELETE FROM _ WHERE _ = _ LIMIT _ -- identifiers removed + +parse +DELETE FROM a WHERE a = b ORDER BY c +---- +DELETE FROM a WHERE a = b ORDER BY c +DELETE FROM a WHERE ((a) = (b)) ORDER BY (c) -- fully parenthetized +DELETE FROM a WHERE a = b ORDER BY c -- literals removed +DELETE FROM _ WHERE _ = _ ORDER BY _ -- identifiers removed + +parse +DELETE FROM a WHERE a = b ORDER BY c LIMIT d +---- +DELETE FROM a WHERE a = b ORDER BY c LIMIT d +DELETE FROM a WHERE ((a) = (b)) ORDER BY (c) LIMIT (d) -- fully parenthetized +DELETE FROM a WHERE a = b ORDER BY c LIMIT d -- literals removed +DELETE FROM _ WHERE _ = _ ORDER BY _ LIMIT _ -- identifiers removed + +parse +DELETE FROM a WHERE a = b RETURNING a, b +---- +DELETE FROM a WHERE a = b RETURNING a, b +DELETE FROM a WHERE ((a) = (b)) RETURNING (a), (b) -- fully parenthetized +DELETE FROM a WHERE a = b RETURNING a, b -- literals removed +DELETE FROM _ WHERE _ = _ RETURNING _, _ -- identifiers removed + +parse +DELETE FROM a WHERE a = b RETURNING 1, 2 +---- +DELETE FROM a WHERE a = b RETURNING 1, 2 +DELETE FROM a WHERE ((a) = (b)) RETURNING (1), (2) -- fully parenthetized +DELETE FROM a WHERE a = b RETURNING _, _ -- literals removed +DELETE FROM _ WHERE _ = _ RETURNING 1, 2 -- identifiers removed + +parse +DELETE FROM a WHERE a = b RETURNING a + b +---- +DELETE FROM a WHERE a = b RETURNING a + b +DELETE FROM a WHERE ((a) = (b)) RETURNING ((a) + (b)) -- fully parenthetized +DELETE FROM a WHERE a = b RETURNING a + b -- literals removed +DELETE FROM _ WHERE _ = _ RETURNING _ + _ -- identifiers removed + +parse +DELETE FROM a WHERE a = b RETURNING NOTHING +---- +DELETE FROM a WHERE a = b RETURNING NOTHING +DELETE FROM a WHERE ((a) = (b)) RETURNING NOTHING -- fully parenthetized +DELETE FROM a WHERE a = b RETURNING NOTHING -- literals removed +DELETE FROM _ WHERE _ = _ RETURNING NOTHING -- identifiers removed + +parse +DELETE FROM a WHERE a = b ORDER BY c LIMIT d RETURNING e +---- +DELETE FROM a WHERE a = b ORDER BY c LIMIT d RETURNING e +DELETE FROM a WHERE ((a) = (b)) ORDER BY (c) LIMIT (d) RETURNING (e) -- fully parenthetized +DELETE FROM a WHERE a = b ORDER BY c LIMIT d RETURNING e -- literals removed +DELETE FROM _ WHERE _ = _ ORDER BY _ LIMIT _ RETURNING _ -- identifiers removed + +parse +DELETE FROM ONLY a WHERE a = b +---- +DELETE FROM a WHERE a = b -- normalized! +DELETE FROM a WHERE ((a) = (b)) -- fully parenthetized +DELETE FROM a WHERE a = b -- literals removed +DELETE FROM _ WHERE _ = _ -- identifiers removed + +parse +DELETE FROM a * WHERE a = b +---- +DELETE FROM a WHERE a = b -- normalized! +DELETE FROM a WHERE ((a) = (b)) -- fully parenthetized +DELETE FROM a WHERE a = b -- literals removed +DELETE FROM _ WHERE _ = _ -- identifiers removed + +parse +DELETE FROM ONLY a * WHERE a = b +---- +DELETE FROM a WHERE a = b -- normalized! +DELETE FROM a WHERE ((a) = (b)) -- fully parenthetized +DELETE FROM a WHERE a = b -- literals removed +DELETE FROM _ WHERE _ = _ -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/drop_database b/pkg/sql/parser/testdata/parse/drop_database new file mode 100644 index 000000000000..823eb0ac75fa --- /dev/null +++ b/pkg/sql/parser/testdata/parse/drop_database @@ -0,0 +1,39 @@ +parse +DROP DATABASE a +---- +DROP DATABASE a +DROP DATABASE a -- fully parenthetized +DROP DATABASE a -- literals removed +DROP DATABASE _ -- identifiers removed + +parse +EXPLAIN DROP DATABASE a +---- +EXPLAIN DROP DATABASE a +EXPLAIN DROP DATABASE a -- fully parenthetized +EXPLAIN DROP DATABASE a -- literals removed +EXPLAIN DROP DATABASE _ -- identifiers removed + +parse +DROP DATABASE IF EXISTS a +---- +DROP DATABASE IF EXISTS a +DROP DATABASE IF EXISTS a -- fully parenthetized +DROP DATABASE IF EXISTS a -- literals removed +DROP DATABASE IF EXISTS _ -- identifiers removed + +parse +DROP DATABASE a CASCADE +---- +DROP DATABASE a CASCADE +DROP DATABASE a CASCADE -- fully parenthetized +DROP DATABASE a CASCADE -- literals removed +DROP DATABASE _ CASCADE -- identifiers removed + +parse +DROP DATABASE a RESTRICT +---- +DROP DATABASE a RESTRICT +DROP DATABASE a RESTRICT -- fully parenthetized +DROP DATABASE a RESTRICT -- literals removed +DROP DATABASE _ RESTRICT -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/drop_index b/pkg/sql/parser/testdata/parse/drop_index new file mode 100644 index 000000000000..54d4839e5b6c --- /dev/null +++ b/pkg/sql/parser/testdata/parse/drop_index @@ -0,0 +1,63 @@ +parse +DROP INDEX a.b@c +---- +DROP INDEX a.b@c +DROP INDEX a.b@c -- fully parenthetized +DROP INDEX a.b@c -- literals removed +DROP INDEX _._@_ -- identifiers removed + +parse +DROP INDEX a +---- +DROP INDEX a +DROP INDEX a -- fully parenthetized +DROP INDEX a -- literals removed +DROP INDEX _ -- identifiers removed + +parse +DROP INDEX a.b +---- +DROP INDEX a.b +DROP INDEX a.b -- fully parenthetized +DROP INDEX a.b -- literals removed +DROP INDEX _._ -- identifiers removed + +parse +DROP INDEX IF EXISTS a.b@c +---- +DROP INDEX IF EXISTS a.b@c +DROP INDEX IF EXISTS a.b@c -- fully parenthetized +DROP INDEX IF EXISTS a.b@c -- literals removed +DROP INDEX IF EXISTS _._@_ -- identifiers removed + +parse +DROP INDEX a.b@c, d@f +---- +DROP INDEX a.b@c, d@f +DROP INDEX a.b@c, d@f -- fully parenthetized +DROP INDEX a.b@c, d@f -- literals removed +DROP INDEX _._@_, _@_ -- identifiers removed + +parse +DROP INDEX IF EXISTS a.b@c, d@f +---- +DROP INDEX IF EXISTS a.b@c, d@f +DROP INDEX IF EXISTS a.b@c, d@f -- fully parenthetized +DROP INDEX IF EXISTS a.b@c, d@f -- literals removed +DROP INDEX IF EXISTS _._@_, _@_ -- identifiers removed + +parse +DROP INDEX a.b@c CASCADE +---- +DROP INDEX a.b@c CASCADE +DROP INDEX a.b@c CASCADE -- fully parenthetized +DROP INDEX a.b@c CASCADE -- literals removed +DROP INDEX _._@_ CASCADE -- identifiers removed + +parse +DROP INDEX IF EXISTS a.b@c RESTRICT +---- +DROP INDEX IF EXISTS a.b@c RESTRICT +DROP INDEX IF EXISTS a.b@c RESTRICT -- fully parenthetized +DROP INDEX IF EXISTS a.b@c RESTRICT -- literals removed +DROP INDEX IF EXISTS _._@_ RESTRICT -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/drop_schema b/pkg/sql/parser/testdata/parse/drop_schema new file mode 100644 index 000000000000..e3d9ecbb1602 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/drop_schema @@ -0,0 +1,127 @@ +parse +DROP SCHEMA a +---- +DROP SCHEMA a +DROP SCHEMA a -- fully parenthetized +DROP SCHEMA a -- literals removed +DROP SCHEMA _ -- identifiers removed + +parse +DROP SCHEMA a, b +---- +DROP SCHEMA a, b +DROP SCHEMA a, b -- fully parenthetized +DROP SCHEMA a, b -- literals removed +DROP SCHEMA _, _ -- identifiers removed + +parse +DROP SCHEMA IF EXISTS a, b, c +---- +DROP SCHEMA IF EXISTS a, b, c +DROP SCHEMA IF EXISTS a, b, c -- fully parenthetized +DROP SCHEMA IF EXISTS a, b, c -- literals removed +DROP SCHEMA IF EXISTS _, _, _ -- identifiers removed + +parse +DROP SCHEMA IF EXISTS a, b CASCADE +---- +DROP SCHEMA IF EXISTS a, b CASCADE +DROP SCHEMA IF EXISTS a, b CASCADE -- fully parenthetized +DROP SCHEMA IF EXISTS a, b CASCADE -- literals removed +DROP SCHEMA IF EXISTS _, _ CASCADE -- identifiers removed + +parse +DROP SCHEMA IF EXISTS a, b RESTRICT +---- +DROP SCHEMA IF EXISTS a, b RESTRICT +DROP SCHEMA IF EXISTS a, b RESTRICT -- fully parenthetized +DROP SCHEMA IF EXISTS a, b RESTRICT -- literals removed +DROP SCHEMA IF EXISTS _, _ RESTRICT -- identifiers removed + +parse +DROP SCHEMA a RESTRICT +---- +DROP SCHEMA a RESTRICT +DROP SCHEMA a RESTRICT -- fully parenthetized +DROP SCHEMA a RESTRICT -- literals removed +DROP SCHEMA _ RESTRICT -- identifiers removed + +parse +DROP SCHEMA a.a +---- +DROP SCHEMA a.a +DROP SCHEMA a.a -- fully parenthetized +DROP SCHEMA a.a -- literals removed +DROP SCHEMA _._ -- identifiers removed + +parse +DROP SCHEMA a.a, b.b, c.c +---- +DROP SCHEMA a.a, b.b, c.c +DROP SCHEMA a.a, b.b, c.c -- fully parenthetized +DROP SCHEMA a.a, b.b, c.c -- literals removed +DROP SCHEMA _._, _._, _._ -- identifiers removed + +parse +DROP SCHEMA a, b.b, c +---- +DROP SCHEMA a, b.b, c +DROP SCHEMA a, b.b, c -- fully parenthetized +DROP SCHEMA a, b.b, c -- literals removed +DROP SCHEMA _, _._, _ -- identifiers removed + +parse +DROP SCHEMA IF EXISTS a.a, b.b, c.c +---- +DROP SCHEMA IF EXISTS a.a, b.b, c.c +DROP SCHEMA IF EXISTS a.a, b.b, c.c -- fully parenthetized +DROP SCHEMA IF EXISTS a.a, b.b, c.c -- literals removed +DROP SCHEMA IF EXISTS _._, _._, _._ -- identifiers removed + +parse +DROP SCHEMA IF EXISTS a, b, c.c +---- +DROP SCHEMA IF EXISTS a, b, c.c +DROP SCHEMA IF EXISTS a, b, c.c -- fully parenthetized +DROP SCHEMA IF EXISTS a, b, c.c -- literals removed +DROP SCHEMA IF EXISTS _, _, _._ -- identifiers removed + +parse +DROP SCHEMA IF EXISTS a.a, b.b CASCADE +---- +DROP SCHEMA IF EXISTS a.a, b.b CASCADE +DROP SCHEMA IF EXISTS a.a, b.b CASCADE -- fully parenthetized +DROP SCHEMA IF EXISTS a.a, b.b CASCADE -- literals removed +DROP SCHEMA IF EXISTS _._, _._ CASCADE -- identifiers removed + +parse +DROP SCHEMA IF EXISTS a.a, b CASCADE +---- +DROP SCHEMA IF EXISTS a.a, b CASCADE +DROP SCHEMA IF EXISTS a.a, b CASCADE -- fully parenthetized +DROP SCHEMA IF EXISTS a.a, b CASCADE -- literals removed +DROP SCHEMA IF EXISTS _._, _ CASCADE -- identifiers removed + +parse +DROP SCHEMA IF EXISTS a.a, b.c RESTRICT +---- +DROP SCHEMA IF EXISTS a.a, b.c RESTRICT +DROP SCHEMA IF EXISTS a.a, b.c RESTRICT -- fully parenthetized +DROP SCHEMA IF EXISTS a.a, b.c RESTRICT -- literals removed +DROP SCHEMA IF EXISTS _._, _._ RESTRICT -- identifiers removed + +parse +DROP SCHEMA IF EXISTS a, b.b RESTRICT +---- +DROP SCHEMA IF EXISTS a, b.b RESTRICT +DROP SCHEMA IF EXISTS a, b.b RESTRICT -- fully parenthetized +DROP SCHEMA IF EXISTS a, b.b RESTRICT -- literals removed +DROP SCHEMA IF EXISTS _, _._ RESTRICT -- identifiers removed + +parse +DROP SCHEMA a.a RESTRICT +---- +DROP SCHEMA a.a RESTRICT +DROP SCHEMA a.a RESTRICT -- fully parenthetized +DROP SCHEMA a.a RESTRICT -- literals removed +DROP SCHEMA _._ RESTRICT -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/drop_sequence b/pkg/sql/parser/testdata/parse/drop_sequence new file mode 100644 index 000000000000..79b683438b81 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/drop_sequence @@ -0,0 +1,71 @@ +parse +DROP SEQUENCE a +---- +DROP SEQUENCE a +DROP SEQUENCE a -- fully parenthetized +DROP SEQUENCE a -- literals removed +DROP SEQUENCE _ -- identifiers removed + +parse +EXPLAIN DROP SEQUENCE a +---- +EXPLAIN DROP SEQUENCE a +EXPLAIN DROP SEQUENCE a -- fully parenthetized +EXPLAIN DROP SEQUENCE a -- literals removed +EXPLAIN DROP SEQUENCE _ -- identifiers removed + +parse +DROP SEQUENCE a.b +---- +DROP SEQUENCE a.b +DROP SEQUENCE a.b -- fully parenthetized +DROP SEQUENCE a.b -- literals removed +DROP SEQUENCE _._ -- identifiers removed + +parse +DROP SEQUENCE a, b +---- +DROP SEQUENCE a, b +DROP SEQUENCE a, b -- fully parenthetized +DROP SEQUENCE a, b -- literals removed +DROP SEQUENCE _, _ -- identifiers removed + +parse +DROP SEQUENCE IF EXISTS a +---- +DROP SEQUENCE IF EXISTS a +DROP SEQUENCE IF EXISTS a -- fully parenthetized +DROP SEQUENCE IF EXISTS a -- literals removed +DROP SEQUENCE IF EXISTS _ -- identifiers removed + +parse +DROP SEQUENCE a RESTRICT +---- +DROP SEQUENCE a RESTRICT +DROP SEQUENCE a RESTRICT -- fully parenthetized +DROP SEQUENCE a RESTRICT -- literals removed +DROP SEQUENCE _ RESTRICT -- identifiers removed + +parse +DROP SEQUENCE IF EXISTS a, b RESTRICT +---- +DROP SEQUENCE IF EXISTS a, b RESTRICT +DROP SEQUENCE IF EXISTS a, b RESTRICT -- fully parenthetized +DROP SEQUENCE IF EXISTS a, b RESTRICT -- literals removed +DROP SEQUENCE IF EXISTS _, _ RESTRICT -- identifiers removed + +parse +DROP SEQUENCE a.b CASCADE +---- +DROP SEQUENCE a.b CASCADE +DROP SEQUENCE a.b CASCADE -- fully parenthetized +DROP SEQUENCE a.b CASCADE -- literals removed +DROP SEQUENCE _._ CASCADE -- identifiers removed + +parse +DROP SEQUENCE a, b CASCADE +---- +DROP SEQUENCE a, b CASCADE +DROP SEQUENCE a, b CASCADE -- fully parenthetized +DROP SEQUENCE a, b CASCADE -- literals removed +DROP SEQUENCE _, _ CASCADE -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/drop_table b/pkg/sql/parser/testdata/parse/drop_table new file mode 100644 index 000000000000..af1c28e79237 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/drop_table @@ -0,0 +1,103 @@ +parse +DROP TABLE a +---- +DROP TABLE a +DROP TABLE a -- fully parenthetized +DROP TABLE a -- literals removed +DROP TABLE _ -- identifiers removed + +parse +EXPLAIN DROP TABLE a +---- +EXPLAIN DROP TABLE a +EXPLAIN DROP TABLE a -- fully parenthetized +EXPLAIN DROP TABLE a -- literals removed +EXPLAIN DROP TABLE _ -- identifiers removed + +parse +DROP TABLE a.b +---- +DROP TABLE a.b +DROP TABLE a.b -- fully parenthetized +DROP TABLE a.b -- literals removed +DROP TABLE _._ -- identifiers removed + +parse +DROP TABLE a, b +---- +DROP TABLE a, b +DROP TABLE a, b -- fully parenthetized +DROP TABLE a, b -- literals removed +DROP TABLE _, _ -- identifiers removed + +parse +DROP TABLE IF EXISTS a +---- +DROP TABLE IF EXISTS a +DROP TABLE IF EXISTS a -- fully parenthetized +DROP TABLE IF EXISTS a -- literals removed +DROP TABLE IF EXISTS _ -- identifiers removed + +parse +DROP TABLE a RESTRICT +---- +DROP TABLE a RESTRICT +DROP TABLE a RESTRICT -- fully parenthetized +DROP TABLE a RESTRICT -- literals removed +DROP TABLE _ RESTRICT -- identifiers removed + +parse +DROP TABLE a.b RESTRICT +---- +DROP TABLE a.b RESTRICT +DROP TABLE a.b RESTRICT -- fully parenthetized +DROP TABLE a.b RESTRICT -- literals removed +DROP TABLE _._ RESTRICT -- identifiers removed + +parse +DROP TABLE a, b RESTRICT +---- +DROP TABLE a, b RESTRICT +DROP TABLE a, b RESTRICT -- fully parenthetized +DROP TABLE a, b RESTRICT -- literals removed +DROP TABLE _, _ RESTRICT -- identifiers removed + +parse +DROP TABLE IF EXISTS a RESTRICT +---- +DROP TABLE IF EXISTS a RESTRICT +DROP TABLE IF EXISTS a RESTRICT -- fully parenthetized +DROP TABLE IF EXISTS a RESTRICT -- literals removed +DROP TABLE IF EXISTS _ RESTRICT -- identifiers removed + +parse +DROP TABLE a CASCADE +---- +DROP TABLE a CASCADE +DROP TABLE a CASCADE -- fully parenthetized +DROP TABLE a CASCADE -- literals removed +DROP TABLE _ CASCADE -- identifiers removed + +parse +DROP TABLE a.b CASCADE +---- +DROP TABLE a.b CASCADE +DROP TABLE a.b CASCADE -- fully parenthetized +DROP TABLE a.b CASCADE -- literals removed +DROP TABLE _._ CASCADE -- identifiers removed + +parse +DROP TABLE a, b CASCADE +---- +DROP TABLE a, b CASCADE +DROP TABLE a, b CASCADE -- fully parenthetized +DROP TABLE a, b CASCADE -- literals removed +DROP TABLE _, _ CASCADE -- identifiers removed + +parse +DROP TABLE IF EXISTS a CASCADE +---- +DROP TABLE IF EXISTS a CASCADE +DROP TABLE IF EXISTS a CASCADE -- fully parenthetized +DROP TABLE IF EXISTS a CASCADE -- literals removed +DROP TABLE IF EXISTS _ CASCADE -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/drop_type b/pkg/sql/parser/testdata/parse/drop_type new file mode 100644 index 000000000000..a29e05e64db9 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/drop_type @@ -0,0 +1,55 @@ +parse +DROP TYPE a +---- +DROP TYPE a +DROP TYPE a -- fully parenthetized +DROP TYPE a -- literals removed +DROP TYPE _ -- identifiers removed + +parse +DROP TYPE a, b, c +---- +DROP TYPE a, b, c +DROP TYPE a, b, c -- fully parenthetized +DROP TYPE a, b, c -- literals removed +DROP TYPE _, _, _ -- identifiers removed + +parse +DROP TYPE db.sc.a, sc.a +---- +DROP TYPE db.sc.a, sc.a +DROP TYPE db.sc.a, sc.a -- fully parenthetized +DROP TYPE db.sc.a, sc.a -- literals removed +DROP TYPE _._._, _._ -- identifiers removed + +parse +DROP TYPE IF EXISTS db.sc.a, sc.a +---- +DROP TYPE IF EXISTS db.sc.a, sc.a +DROP TYPE IF EXISTS db.sc.a, sc.a -- fully parenthetized +DROP TYPE IF EXISTS db.sc.a, sc.a -- literals removed +DROP TYPE IF EXISTS _._._, _._ -- identifiers removed + +parse +DROP TYPE db.sc.a, sc.a CASCADE +---- +DROP TYPE db.sc.a, sc.a CASCADE +DROP TYPE db.sc.a, sc.a CASCADE -- fully parenthetized +DROP TYPE db.sc.a, sc.a CASCADE -- literals removed +DROP TYPE _._._, _._ CASCADE -- identifiers removed + +parse +DROP TYPE IF EXISTS 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 CASCADE -- fully parenthetized +DROP TYPE IF EXISTS db.sc.a, sc.a CASCADE -- literals removed +DROP TYPE IF EXISTS _._._, _._ CASCADE -- identifiers removed + +parse +DROP TYPE IF EXISTS db.sc.a, sc.a RESTRICT +---- +DROP TYPE IF EXISTS db.sc.a, sc.a RESTRICT +DROP TYPE IF EXISTS db.sc.a, sc.a RESTRICT -- fully parenthetized +DROP TYPE IF EXISTS db.sc.a, sc.a RESTRICT -- literals removed +DROP TYPE IF EXISTS _._._, _._ RESTRICT -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/drop_user b/pkg/sql/parser/testdata/parse/drop_user new file mode 100644 index 000000000000..2d30dcbfc1da --- /dev/null +++ b/pkg/sql/parser/testdata/parse/drop_user @@ -0,0 +1,35 @@ +parse +DROP USER foo, bar +---- +DROP USER 'foo', 'bar' -- normalized! +DROP USER ('foo'), ('bar') -- fully parenthetized +DROP USER _, _ -- literals removed +DROP USER '_', '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +DROP USER 'foo', 'bar' -- identifiers removed + +parse +DROP USER IF EXISTS foo, bar +---- +DROP USER IF EXISTS 'foo', 'bar' -- normalized! +DROP USER IF EXISTS ('foo'), ('bar') -- fully parenthetized +DROP USER IF EXISTS _, _ -- literals removed +DROP USER IF EXISTS '_', '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +DROP USER IF EXISTS 'foo', 'bar' -- identifiers removed + +parse +DROP ROLE foo, bar +---- +DROP ROLE 'foo', 'bar' -- normalized! +DROP ROLE ('foo'), ('bar') -- fully parenthetized +DROP ROLE _, _ -- literals removed +DROP ROLE '_', '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +DROP ROLE 'foo', 'bar' -- identifiers removed + +parse +DROP ROLE IF EXISTS foo, bar +---- +DROP ROLE IF EXISTS 'foo', 'bar' -- normalized! +DROP ROLE IF EXISTS ('foo'), ('bar') -- fully parenthetized +DROP ROLE IF EXISTS _, _ -- literals removed +DROP ROLE IF EXISTS '_', '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +DROP ROLE IF EXISTS 'foo', 'bar' -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/drop_view b/pkg/sql/parser/testdata/parse/drop_view new file mode 100644 index 000000000000..936aa497b27d --- /dev/null +++ b/pkg/sql/parser/testdata/parse/drop_view @@ -0,0 +1,79 @@ +parse +DROP VIEW a +---- +DROP VIEW a +DROP VIEW a -- fully parenthetized +DROP VIEW a -- literals removed +DROP VIEW _ -- identifiers removed + +parse +DROP VIEW a.b +---- +DROP VIEW a.b +DROP VIEW a.b -- fully parenthetized +DROP VIEW a.b -- literals removed +DROP VIEW _._ -- identifiers removed + +parse +DROP VIEW a, b +---- +DROP VIEW a, b +DROP VIEW a, b -- fully parenthetized +DROP VIEW a, b -- literals removed +DROP VIEW _, _ -- identifiers removed + +parse +DROP VIEW IF EXISTS a +---- +DROP VIEW IF EXISTS a +DROP VIEW IF EXISTS a -- fully parenthetized +DROP VIEW IF EXISTS a -- literals removed +DROP VIEW IF EXISTS _ -- identifiers removed + +parse +DROP VIEW a RESTRICT +---- +DROP VIEW a RESTRICT +DROP VIEW a RESTRICT -- fully parenthetized +DROP VIEW a RESTRICT -- literals removed +DROP VIEW _ RESTRICT -- identifiers removed + +parse +DROP VIEW IF EXISTS a, b RESTRICT +---- +DROP VIEW IF EXISTS a, b RESTRICT +DROP VIEW IF EXISTS a, b RESTRICT -- fully parenthetized +DROP VIEW IF EXISTS a, b RESTRICT -- literals removed +DROP VIEW IF EXISTS _, _ RESTRICT -- identifiers removed + +parse +DROP VIEW a.b CASCADE +---- +DROP VIEW a.b CASCADE +DROP VIEW a.b CASCADE -- fully parenthetized +DROP VIEW a.b CASCADE -- literals removed +DROP VIEW _._ CASCADE -- identifiers removed + +parse +DROP VIEW a, b CASCADE +---- +DROP VIEW a, b CASCADE +DROP VIEW a, b CASCADE -- fully parenthetized +DROP VIEW a, b CASCADE -- literals removed +DROP VIEW _, _ CASCADE -- identifiers removed + +parse +DROP MATERIALIZED VIEW a, b +---- +DROP MATERIALIZED VIEW a, b +DROP MATERIALIZED VIEW a, b -- fully parenthetized +DROP MATERIALIZED VIEW a, b -- literals removed +DROP MATERIALIZED VIEW _, _ -- identifiers removed + +parse +DROP MATERIALIZED VIEW IF EXISTS a +---- +DROP MATERIALIZED VIEW IF EXISTS a +DROP MATERIALIZED VIEW IF EXISTS a -- fully parenthetized +DROP MATERIALIZED VIEW IF EXISTS a -- literals removed +DROP MATERIALIZED VIEW IF EXISTS _ -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/empty b/pkg/sql/parser/testdata/parse/empty new file mode 100644 index 000000000000..d8013d84a965 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/empty @@ -0,0 +1,10 @@ +parse + +---- +---- + + -- fully parenthetized + -- literals removed + -- identifiers removed +---- +---- diff --git a/pkg/sql/parser/testdata/parse/explain b/pkg/sql/parser/testdata/parse/explain new file mode 100644 index 000000000000..d1e9e86eac0d --- /dev/null +++ b/pkg/sql/parser/testdata/parse/explain @@ -0,0 +1,95 @@ +parse +EXPLAIN SELECT 1 +---- +EXPLAIN SELECT 1 +EXPLAIN SELECT (1) -- fully parenthetized +EXPLAIN SELECT _ -- literals removed +EXPLAIN SELECT 1 -- identifiers removed + +parse +EXPLAIN EXPLAIN SELECT 1 +---- +EXPLAIN EXPLAIN SELECT 1 +EXPLAIN EXPLAIN SELECT (1) -- fully parenthetized +EXPLAIN EXPLAIN SELECT _ -- literals removed +EXPLAIN EXPLAIN SELECT 1 -- identifiers removed + +parse +EXPLAIN (DISTSQL) SELECT 1 +---- +EXPLAIN (DISTSQL) SELECT 1 +EXPLAIN (DISTSQL) SELECT (1) -- fully parenthetized +EXPLAIN (DISTSQL) SELECT _ -- literals removed +EXPLAIN (DISTSQL) SELECT 1 -- identifiers removed + +parse +EXPLAIN (DISTSQL, JSON) SELECT 1 +---- +EXPLAIN (DISTSQL, JSON) SELECT 1 +EXPLAIN (DISTSQL, JSON) SELECT (1) -- fully parenthetized +EXPLAIN (DISTSQL, JSON) SELECT _ -- literals removed +EXPLAIN (DISTSQL, JSON) SELECT 1 -- identifiers removed + +parse +EXPLAIN (OPT, VERBOSE) SELECT 1 +---- +EXPLAIN (OPT, VERBOSE) SELECT 1 +EXPLAIN (OPT, VERBOSE) SELECT (1) -- fully parenthetized +EXPLAIN (OPT, VERBOSE) SELECT _ -- literals removed +EXPLAIN (OPT, VERBOSE) SELECT 1 -- identifiers removed + +parse +EXPLAIN ANALYZE (DISTSQL) SELECT 1 +---- +EXPLAIN ANALYZE (DISTSQL) SELECT 1 +EXPLAIN ANALYZE (DISTSQL) SELECT (1) -- fully parenthetized +EXPLAIN ANALYZE (DISTSQL) SELECT _ -- literals removed +EXPLAIN ANALYZE (DISTSQL) SELECT 1 -- identifiers removed + +parse +EXPLAIN ANALYZE (DEBUG) SELECT 1 +---- +EXPLAIN ANALYZE (DEBUG) SELECT 1 +EXPLAIN ANALYZE (DEBUG) SELECT (1) -- fully parenthetized +EXPLAIN ANALYZE (DEBUG) SELECT _ -- literals removed +EXPLAIN ANALYZE (DEBUG) SELECT 1 -- identifiers removed + +parse +EXPLAIN ANALYZE SELECT 1 +---- +EXPLAIN ANALYZE SELECT 1 +EXPLAIN ANALYZE SELECT (1) -- fully parenthetized +EXPLAIN ANALYZE SELECT _ -- literals removed +EXPLAIN ANALYZE SELECT 1 -- identifiers removed + +parse +EXPLAIN ANALYZE (PLAN) SELECT 1 +---- +EXPLAIN ANALYZE SELECT 1 -- normalized! +EXPLAIN ANALYZE SELECT (1) -- fully parenthetized +EXPLAIN ANALYZE SELECT _ -- literals removed +EXPLAIN ANALYZE SELECT 1 -- identifiers removed + +parse +EXPLAIN ANALYSE SELECT 1 +---- +EXPLAIN ANALYZE SELECT 1 -- normalized! +EXPLAIN ANALYZE SELECT (1) -- fully parenthetized +EXPLAIN ANALYZE SELECT _ -- literals removed +EXPLAIN ANALYZE SELECT 1 -- identifiers removed + +parse +EXPLAIN ANALYSE (PLAN) SELECT 1 +---- +EXPLAIN ANALYZE SELECT 1 -- normalized! +EXPLAIN ANALYZE SELECT (1) -- fully parenthetized +EXPLAIN ANALYZE SELECT _ -- literals removed +EXPLAIN ANALYZE SELECT 1 -- identifiers removed + +parse +EXPLAIN (VERBOSE, OPT) SELECT 1 +---- +EXPLAIN (OPT, VERBOSE) SELECT 1 -- normalized! +EXPLAIN (OPT, VERBOSE) SELECT (1) -- fully parenthetized +EXPLAIN (OPT, VERBOSE) SELECT _ -- literals removed +EXPLAIN (OPT, VERBOSE) SELECT 1 -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/grant_revoke b/pkg/sql/parser/testdata/parse/grant_revoke new file mode 100644 index 000000000000..f2b063b40c7d --- /dev/null +++ b/pkg/sql/parser/testdata/parse/grant_revoke @@ -0,0 +1,418 @@ +## Tables are the default, but can also be specified with +## GRANT x ON TABLE y. However, the stringer does not output TABLE. + +parse +GRANT SELECT ON TABLE foo TO root +---- +GRANT SELECT ON TABLE foo TO root +GRANT SELECT ON TABLE (foo) TO root -- fully parenthetized +GRANT SELECT ON TABLE foo TO root -- literals removed +GRANT SELECT ON TABLE _ TO _ -- identifiers removed + +parse +GRANT SELECT ON foo TO root +---- +GRANT SELECT ON TABLE foo TO root -- normalized! +GRANT SELECT ON TABLE (foo) TO root -- fully parenthetized +GRANT SELECT ON TABLE foo TO root -- literals removed +GRANT SELECT ON TABLE _ TO _ -- identifiers removed + +parse +GRANT SELECT, DELETE, UPDATE ON TABLE foo, db.foo TO root, bar +---- +GRANT SELECT, DELETE, UPDATE ON TABLE foo, db.foo TO root, bar +GRANT SELECT, DELETE, UPDATE ON TABLE (foo), (db.foo) TO root, bar -- fully parenthetized +GRANT SELECT, DELETE, UPDATE ON TABLE foo, db.foo TO root, bar -- literals removed +GRANT SELECT, DELETE, UPDATE ON TABLE _, _._ TO _, _ -- identifiers removed + + +parse +GRANT SELECT, DELETE, UPDATE ON foo, db.foo TO root, bar +---- +GRANT SELECT, DELETE, UPDATE ON TABLE foo, db.foo TO root, bar -- normalized! +GRANT SELECT, DELETE, UPDATE ON TABLE (foo), (db.foo) TO root, bar -- fully parenthetized +GRANT SELECT, DELETE, UPDATE ON TABLE foo, db.foo TO root, bar -- literals removed +GRANT SELECT, DELETE, UPDATE ON TABLE _, _._ TO _, _ -- identifiers removed + +parse +GRANT SELECT ON role TO root +---- +GRANT SELECT ON TABLE role TO root -- normalized! +GRANT SELECT ON TABLE (role) TO root -- fully parenthetized +GRANT SELECT ON TABLE role TO root -- literals removed +GRANT SELECT ON TABLE _ TO _ -- identifiers removed + +parse +REVOKE SELECT ON foo FROM root +---- +REVOKE SELECT ON TABLE foo FROM root -- normalized! +REVOKE SELECT ON TABLE (foo) FROM root -- fully parenthetized +REVOKE SELECT ON TABLE foo FROM root -- literals removed +REVOKE SELECT ON TABLE _ FROM _ -- identifiers removed + +parse +GRANT DROP ON DATABASE foo TO root +---- +GRANT DROP ON DATABASE foo TO root +GRANT DROP ON DATABASE foo TO root -- fully parenthetized +GRANT DROP ON DATABASE foo TO root -- literals removed +GRANT DROP ON DATABASE _ TO _ -- identifiers removed + +parse +GRANT ALL ON DATABASE foo TO root, test +---- +GRANT ALL ON DATABASE foo TO root, test +GRANT ALL ON DATABASE foo TO root, test -- fully parenthetized +GRANT ALL ON DATABASE foo TO root, test -- literals removed +GRANT ALL ON DATABASE _ TO _, _ -- identifiers removed + +parse +GRANT ALL PRIVILEGES ON DATABASE foo TO root +---- +GRANT ALL ON DATABASE foo TO root -- normalized! +GRANT ALL ON DATABASE foo TO root -- fully parenthetized +GRANT ALL ON DATABASE foo TO root -- literals removed +GRANT ALL ON DATABASE _ TO _ -- identifiers removed + + +parse +GRANT SELECT, INSERT ON DATABASE bar TO foo, bar, baz +---- +GRANT SELECT, INSERT ON DATABASE bar TO foo, bar, baz +GRANT SELECT, INSERT ON DATABASE bar TO foo, bar, baz -- fully parenthetized +GRANT SELECT, INSERT ON DATABASE bar TO foo, bar, baz -- literals removed +GRANT SELECT, INSERT ON DATABASE _ TO _, _, _ -- identifiers removed + +parse +GRANT SELECT, INSERT ON DATABASE db1, db2 TO foo, bar, baz +---- +GRANT SELECT, INSERT ON DATABASE db1, db2 TO foo, bar, baz +GRANT SELECT, INSERT ON DATABASE db1, db2 TO foo, bar, baz -- fully parenthetized +GRANT SELECT, INSERT ON DATABASE db1, db2 TO foo, bar, baz -- literals removed +GRANT SELECT, INSERT ON DATABASE _, _ TO _, _, _ -- identifiers removed + +parse +GRANT SELECT, INSERT ON DATABASE db1, db2 TO "test-user" +---- +GRANT SELECT, INSERT ON DATABASE db1, db2 TO "test-user" +GRANT SELECT, INSERT ON DATABASE db1, db2 TO "test-user" -- fully parenthetized +GRANT SELECT, INSERT ON DATABASE db1, db2 TO "test-user" -- literals removed +GRANT SELECT, INSERT ON DATABASE _, _ TO _ -- identifiers removed + +parse +GRANT rolea, roleb TO usera, userb +---- +GRANT rolea, roleb TO usera, userb +GRANT rolea, roleb TO usera, userb -- fully parenthetized +GRANT rolea, roleb TO usera, userb -- literals removed +GRANT _, _ TO _, _ -- identifiers removed + +parse +GRANT rolea, roleb TO usera, userb WITH ADMIN OPTION +---- +GRANT rolea, roleb TO usera, userb WITH ADMIN OPTION +GRANT rolea, roleb TO usera, userb WITH ADMIN OPTION -- fully parenthetized +GRANT rolea, roleb TO usera, userb WITH ADMIN OPTION -- literals removed +GRANT _, _ TO _, _ WITH ADMIN OPTION -- identifiers removed + + +parse +GRANT ALL PRIVILEGES ON TABLE foo TO root +---- +GRANT ALL ON TABLE foo TO root -- normalized! +GRANT ALL ON TABLE (foo) TO root -- fully parenthetized +GRANT ALL ON TABLE foo TO root -- literals removed +GRANT ALL ON TABLE _ TO _ -- identifiers removed + +## GRANT ON TYPE. + +parse +GRANT USAGE ON TYPE foo TO root +---- +GRANT USAGE ON TYPE foo TO root +GRANT USAGE ON TYPE foo TO root -- fully parenthetized +GRANT USAGE ON TYPE foo TO root -- literals removed +GRANT USAGE ON TYPE _ TO _ -- identifiers removed + +parse +GRANT USAGE, GRANT ON TYPE foo TO root +---- +GRANT USAGE, GRANT ON TYPE foo TO root +GRANT USAGE, GRANT ON TYPE foo TO root -- fully parenthetized +GRANT USAGE, GRANT ON TYPE foo TO root -- literals removed +GRANT USAGE, GRANT ON TYPE _ TO _ -- identifiers removed + +parse +GRANT ALL ON TYPE foo TO root +---- +GRANT ALL ON TYPE foo TO root +GRANT ALL ON TYPE foo TO root -- fully parenthetized +GRANT ALL ON TYPE foo TO root -- literals removed +GRANT ALL ON TYPE _ TO _ -- identifiers removed + +## GRANT ON SCHEMA. + +parse +GRANT USAGE ON SCHEMA foo TO root +---- +GRANT USAGE ON SCHEMA foo TO root +GRANT USAGE ON SCHEMA foo TO root -- fully parenthetized +GRANT USAGE ON SCHEMA foo TO root -- literals removed +GRANT USAGE ON SCHEMA _ TO _ -- identifiers removed + +parse +GRANT USAGE ON SCHEMA foo.bar TO root +---- +GRANT USAGE ON SCHEMA foo.bar TO root +GRANT USAGE ON SCHEMA foo.bar TO root -- fully parenthetized +GRANT USAGE ON SCHEMA foo.bar TO root -- literals removed +GRANT USAGE ON SCHEMA _._ TO _ -- identifiers removed + +parse +GRANT USAGE, GRANT, CREATE ON SCHEMA foo TO root +---- +GRANT USAGE, GRANT, CREATE ON SCHEMA foo TO root +GRANT USAGE, GRANT, CREATE ON SCHEMA foo TO root -- fully parenthetized +GRANT USAGE, GRANT, CREATE ON SCHEMA foo TO root -- literals removed +GRANT USAGE, GRANT, CREATE ON SCHEMA _ TO _ -- identifiers removed + +parse +GRANT USAGE, GRANT, CREATE ON SCHEMA foo.bar TO root +---- +GRANT USAGE, GRANT, CREATE ON SCHEMA foo.bar TO root +GRANT USAGE, GRANT, CREATE ON SCHEMA foo.bar TO root -- fully parenthetized +GRANT USAGE, GRANT, CREATE ON SCHEMA foo.bar TO root -- literals removed +GRANT USAGE, GRANT, CREATE ON SCHEMA _._ TO _ -- identifiers removed + +parse +GRANT ALL ON SCHEMA foo, bar, baz TO root +---- +GRANT ALL ON SCHEMA foo, bar, baz TO root +GRANT ALL ON SCHEMA foo, bar, baz TO root -- fully parenthetized +GRANT ALL ON SCHEMA foo, bar, baz TO root -- literals removed +GRANT ALL ON SCHEMA _, _, _ TO _ -- identifiers removed + +parse +GRANT ALL ON SCHEMA a.b, c.d, e.f TO root +---- +GRANT ALL ON SCHEMA a.b, c.d, e.f TO root +GRANT ALL ON SCHEMA a.b, c.d, e.f TO root -- fully parenthetized +GRANT ALL ON SCHEMA a.b, c.d, e.f TO root -- literals removed +GRANT ALL ON SCHEMA _._, _._, _._ TO _ -- identifiers removed + +parse +GRANT ALL PRIVILEGES ON SCHEMA foo TO root +---- +GRANT ALL ON SCHEMA foo TO root -- normalized! +GRANT ALL ON SCHEMA foo TO root -- fully parenthetized +GRANT ALL ON SCHEMA foo TO root -- literals removed +GRANT ALL ON SCHEMA _ TO _ -- identifiers removed + +parse +GRANT ALL PRIVILEGES ON SCHEMA foo.bar TO root +---- +GRANT ALL ON SCHEMA foo.bar TO root -- normalized! +GRANT ALL ON SCHEMA foo.bar TO root -- fully parenthetized +GRANT ALL ON SCHEMA foo.bar TO root -- literals removed +GRANT ALL ON SCHEMA _._ TO _ -- identifiers removed + +parse +GRANT ALL PRIVILEGES ON SCHEMA a.b, c.d TO root +---- +GRANT ALL ON SCHEMA a.b, c.d TO root -- normalized! +GRANT ALL ON SCHEMA a.b, c.d TO root -- fully parenthetized +GRANT ALL ON SCHEMA a.b, c.d TO root -- literals removed +GRANT ALL ON SCHEMA _._, _._ TO _ -- identifiers removed + +## Tables are the default, but can also be specified with +## REVOKE x ON TABLE y. However, the stringer does not output TABLE. + +parse +REVOKE SELECT ON TABLE foo FROM root +---- +REVOKE SELECT ON TABLE foo FROM root +REVOKE SELECT ON TABLE (foo) FROM root -- fully parenthetized +REVOKE SELECT ON TABLE foo FROM root -- literals removed +REVOKE SELECT ON TABLE _ FROM _ -- identifiers removed + +parse +REVOKE UPDATE, DELETE ON TABLE foo, db.foo FROM root, bar +---- +REVOKE UPDATE, DELETE ON TABLE foo, db.foo FROM root, bar +REVOKE UPDATE, DELETE ON TABLE (foo), (db.foo) FROM root, bar -- fully parenthetized +REVOKE UPDATE, DELETE ON TABLE foo, db.foo FROM root, bar -- literals removed +REVOKE UPDATE, DELETE ON TABLE _, _._ FROM _, _ -- identifiers removed + +parse +REVOKE UPDATE, DELETE ON foo, db.foo FROM root, bar +---- +REVOKE UPDATE, DELETE ON TABLE foo, db.foo FROM root, bar -- normalized! +REVOKE UPDATE, DELETE ON TABLE (foo), (db.foo) FROM root, bar -- fully parenthetized +REVOKE UPDATE, DELETE ON TABLE foo, db.foo FROM root, bar -- literals removed +REVOKE UPDATE, DELETE ON TABLE _, _._ FROM _, _ -- identifiers removed + +parse +REVOKE INSERT ON DATABASE foo FROM root +---- +REVOKE INSERT ON DATABASE foo FROM root +REVOKE INSERT ON DATABASE foo FROM root -- fully parenthetized +REVOKE INSERT ON DATABASE foo FROM root -- literals removed +REVOKE INSERT ON DATABASE _ FROM _ -- identifiers removed + +parse +REVOKE ALL ON DATABASE foo FROM root, test +---- +REVOKE ALL ON DATABASE foo FROM root, test +REVOKE ALL ON DATABASE foo FROM root, test -- fully parenthetized +REVOKE ALL ON DATABASE foo FROM root, test -- literals removed +REVOKE ALL ON DATABASE _ FROM _, _ -- identifiers removed + +parse +REVOKE ALL PRIVILEGES ON DATABASE foo FROM root +---- +REVOKE ALL ON DATABASE foo FROM root -- normalized! +REVOKE ALL ON DATABASE foo FROM root -- fully parenthetized +REVOKE ALL ON DATABASE foo FROM root -- literals removed +REVOKE ALL ON DATABASE _ FROM _ -- identifiers removed + + +parse +REVOKE SELECT, INSERT ON DATABASE bar FROM foo, bar, baz +---- +REVOKE SELECT, INSERT ON DATABASE bar FROM foo, bar, baz +REVOKE SELECT, INSERT ON DATABASE bar FROM foo, bar, baz -- fully parenthetized +REVOKE SELECT, INSERT ON DATABASE bar FROM foo, bar, baz -- literals removed +REVOKE SELECT, INSERT ON DATABASE _ FROM _, _, _ -- identifiers removed + +parse +REVOKE SELECT, INSERT ON DATABASE db1, db2 FROM foo, bar, baz +---- +REVOKE SELECT, INSERT ON DATABASE db1, db2 FROM foo, bar, baz +REVOKE SELECT, INSERT ON DATABASE db1, db2 FROM foo, bar, baz -- fully parenthetized +REVOKE SELECT, INSERT ON DATABASE db1, db2 FROM foo, bar, baz -- literals removed +REVOKE SELECT, INSERT ON DATABASE _, _ FROM _, _, _ -- identifiers removed + +parse +REVOKE rolea, roleb FROM usera, userb +---- +REVOKE rolea, roleb FROM usera, userb +REVOKE rolea, roleb FROM usera, userb -- fully parenthetized +REVOKE rolea, roleb FROM usera, userb -- literals removed +REVOKE _, _ FROM _, _ -- identifiers removed + +parse +REVOKE ADMIN OPTION FOR rolea, roleb FROM usera, userb +---- +REVOKE ADMIN OPTION FOR rolea, roleb FROM usera, userb +REVOKE ADMIN OPTION FOR rolea, roleb FROM usera, userb -- fully parenthetized +REVOKE ADMIN OPTION FOR rolea, roleb FROM usera, userb -- literals removed +REVOKE ADMIN OPTION FOR _, _ FROM _, _ -- identifiers removed + +parse +REVOKE ALL PRIVILEGES ON TABLE foo FROM root +---- +REVOKE ALL ON TABLE foo FROM root -- normalized! +REVOKE ALL ON TABLE (foo) FROM root -- fully parenthetized +REVOKE ALL ON TABLE foo FROM root -- literals removed +REVOKE ALL ON TABLE _ FROM _ -- identifiers removed + + +## REVOKE ON TYPE. + +parse +REVOKE USAGE ON TYPE foo FROM root +---- +REVOKE USAGE ON TYPE foo FROM root +REVOKE USAGE ON TYPE foo FROM root -- fully parenthetized +REVOKE USAGE ON TYPE foo FROM root -- literals removed +REVOKE USAGE ON TYPE _ FROM _ -- identifiers removed + +parse +REVOKE USAGE, GRANT ON TYPE foo FROM root +---- +REVOKE USAGE, GRANT ON TYPE foo FROM root +REVOKE USAGE, GRANT ON TYPE foo FROM root -- fully parenthetized +REVOKE USAGE, GRANT ON TYPE foo FROM root -- literals removed +REVOKE USAGE, GRANT ON TYPE _ FROM _ -- identifiers removed + +parse +REVOKE ALL ON TYPE foo FROM root +---- +REVOKE ALL ON TYPE foo FROM root +REVOKE ALL ON TYPE foo FROM root -- fully parenthetized +REVOKE ALL ON TYPE foo FROM root -- literals removed +REVOKE ALL ON TYPE _ FROM _ -- identifiers removed + +## REVOKE ON SCHEMA. + +parse +REVOKE USAGE ON SCHEMA foo FROM root +---- +REVOKE USAGE ON SCHEMA foo FROM root +REVOKE USAGE ON SCHEMA foo FROM root -- fully parenthetized +REVOKE USAGE ON SCHEMA foo FROM root -- literals removed +REVOKE USAGE ON SCHEMA _ FROM _ -- identifiers removed + +parse +REVOKE USAGE ON SCHEMA foo.bar FROM root +---- +REVOKE USAGE ON SCHEMA foo.bar FROM root +REVOKE USAGE ON SCHEMA foo.bar FROM root -- fully parenthetized +REVOKE USAGE ON SCHEMA foo.bar FROM root -- literals removed +REVOKE USAGE ON SCHEMA _._ FROM _ -- identifiers removed + +parse +REVOKE USAGE, GRANT, CREATE ON SCHEMA foo FROM root +---- +REVOKE USAGE, GRANT, CREATE ON SCHEMA foo FROM root +REVOKE USAGE, GRANT, CREATE ON SCHEMA foo FROM root -- fully parenthetized +REVOKE USAGE, GRANT, CREATE ON SCHEMA foo FROM root -- literals removed +REVOKE USAGE, GRANT, CREATE ON SCHEMA _ FROM _ -- identifiers removed + +parse +REVOKE USAGE, GRANT, CREATE ON SCHEMA foo.bar FROM root +---- +REVOKE USAGE, GRANT, CREATE ON SCHEMA foo.bar FROM root +REVOKE USAGE, GRANT, CREATE ON SCHEMA foo.bar FROM root -- fully parenthetized +REVOKE USAGE, GRANT, CREATE ON SCHEMA foo.bar FROM root -- literals removed +REVOKE USAGE, GRANT, CREATE ON SCHEMA _._ FROM _ -- identifiers removed + +parse +REVOKE ALL ON SCHEMA foo, bar, baz FROM root +---- +REVOKE ALL ON SCHEMA foo, bar, baz FROM root +REVOKE ALL ON SCHEMA foo, bar, baz FROM root -- fully parenthetized +REVOKE ALL ON SCHEMA foo, bar, baz FROM root -- literals removed +REVOKE ALL ON SCHEMA _, _, _ FROM _ -- identifiers removed + +parse +REVOKE ALL ON SCHEMA a.b, c.d, e.f FROM root +---- +REVOKE ALL ON SCHEMA a.b, c.d, e.f FROM root +REVOKE ALL ON SCHEMA a.b, c.d, e.f FROM root -- fully parenthetized +REVOKE ALL ON SCHEMA a.b, c.d, e.f FROM root -- literals removed +REVOKE ALL ON SCHEMA _._, _._, _._ FROM _ -- identifiers removed + +parse +REVOKE ALL PRIVILEGES ON SCHEMA foo FROM root +---- +REVOKE ALL ON SCHEMA foo FROM root -- normalized! +REVOKE ALL ON SCHEMA foo FROM root -- fully parenthetized +REVOKE ALL ON SCHEMA foo FROM root -- literals removed +REVOKE ALL ON SCHEMA _ FROM _ -- identifiers removed + +parse +REVOKE ALL PRIVILEGES ON SCHEMA foo.bar FROM root +---- +REVOKE ALL ON SCHEMA foo.bar FROM root -- normalized! +REVOKE ALL ON SCHEMA foo.bar FROM root -- fully parenthetized +REVOKE ALL ON SCHEMA foo.bar FROM root -- literals removed +REVOKE ALL ON SCHEMA _._ FROM _ -- identifiers removed + +parse +REVOKE ALL PRIVILEGES ON SCHEMA a.b, c.d FROM root +---- +REVOKE ALL ON SCHEMA a.b, c.d FROM root -- normalized! +REVOKE ALL ON SCHEMA a.b, c.d FROM root -- fully parenthetized +REVOKE ALL ON SCHEMA a.b, c.d FROM root -- literals removed +REVOKE ALL ON SCHEMA _._, _._ FROM _ -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/import_export b/pkg/sql/parser/testdata/parse/import_export new file mode 100644 index 000000000000..9d5f0f851694 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/import_export @@ -0,0 +1,152 @@ +parse +IMPORT TABLE foo CREATE USING 'nodelocal://0/some/file' CSV DATA ('path/to/some/file', $1) WITH temp = 'path/to/temp' +---- +IMPORT TABLE foo CREATE USING 'nodelocal://0/some/file' CSV DATA ('path/to/some/file', $1) WITH temp = 'path/to/temp' +IMPORT TABLE foo CREATE USING ('nodelocal://0/some/file') CSV DATA (('path/to/some/file'), ($1)) WITH temp = ('path/to/temp') -- fully parenthetized +IMPORT TABLE foo CREATE USING _ CSV DATA (_, $1) WITH temp = _ -- literals removed +IMPORT TABLE foo CREATE USING '_' CSV DATA ('_', $1) WITH temp = '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +IMPORT TABLE _ CREATE USING 'nodelocal://0/some/file' CSV DATA ('path/to/some/file', $1) WITH _ = 'path/to/temp' -- identifiers removed + +parse +EXPLAIN IMPORT TABLE foo CREATE USING 'nodelocal://0/some/file' CSV DATA ('path/to/some/file', $1) WITH temp = 'path/to/temp' +---- +EXPLAIN IMPORT TABLE foo CREATE USING 'nodelocal://0/some/file' CSV DATA ('path/to/some/file', $1) WITH temp = 'path/to/temp' +EXPLAIN IMPORT TABLE foo CREATE USING ('nodelocal://0/some/file') CSV DATA (('path/to/some/file'), ($1)) WITH temp = ('path/to/temp') -- fully parenthetized +EXPLAIN IMPORT TABLE foo CREATE USING _ CSV DATA (_, $1) WITH temp = _ -- literals removed +EXPLAIN IMPORT TABLE foo CREATE USING '_' CSV DATA ('_', $1) WITH temp = '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +EXPLAIN IMPORT TABLE _ CREATE USING 'nodelocal://0/some/file' CSV DATA ('path/to/some/file', $1) WITH _ = 'path/to/temp' -- identifiers removed + +parse +IMPORT TABLE foo CREATE USING 'nodelocal://0/some/file' DELIMITED DATA ('path/to/some/file', $1) +---- +IMPORT TABLE foo CREATE USING 'nodelocal://0/some/file' DELIMITED DATA ('path/to/some/file', $1) +IMPORT TABLE foo CREATE USING ('nodelocal://0/some/file') DELIMITED DATA (('path/to/some/file'), ($1)) -- fully parenthetized +IMPORT TABLE foo CREATE USING _ DELIMITED DATA (_, $1) -- literals removed +IMPORT TABLE foo CREATE USING '_' DELIMITED DATA ('_', $1) -- UNEXPECTED REPARSED AST WITHOUT LITERALS +IMPORT TABLE _ CREATE USING 'nodelocal://0/some/file' DELIMITED DATA ('path/to/some/file', $1) -- identifiers removed + +parse +IMPORT TABLE foo (id INT8 PRIMARY KEY, email STRING, age INT8) CSV DATA ('path/to/some/file', $1) WITH temp = 'path/to/temp' +---- +IMPORT TABLE foo (id INT8 PRIMARY KEY, email STRING, age INT8) CSV DATA ('path/to/some/file', $1) WITH temp = 'path/to/temp' +IMPORT TABLE foo (id INT8 PRIMARY KEY, email STRING, age INT8) CSV DATA (('path/to/some/file'), ($1)) WITH temp = ('path/to/temp') -- fully parenthetized +IMPORT TABLE foo (id INT8 PRIMARY KEY, email STRING, age INT8) CSV DATA (_, $1) WITH temp = _ -- literals removed +IMPORT TABLE foo (id INT8 PRIMARY KEY, email STRING, age INT8) CSV DATA ('_', $1) WITH temp = '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +IMPORT TABLE _ (_ INT8 PRIMARY KEY, _ STRING, _ INT8) CSV DATA ('path/to/some/file', $1) WITH _ = 'path/to/temp' -- identifiers removed + +parse +IMPORT TABLE foo (id INT8, email STRING, age INT8) CSV DATA ('path/to/some/file', $1) WITH comma = ',', "nullif" = 'n/a', temp = $2 +---- +IMPORT TABLE foo (id INT8, email STRING, age INT8) CSV DATA ('path/to/some/file', $1) WITH comma = ',', "nullif" = 'n/a', temp = $2 +IMPORT TABLE foo (id INT8, email STRING, age INT8) CSV DATA (('path/to/some/file'), ($1)) WITH comma = (','), "nullif" = ('n/a'), temp = ($2) -- fully parenthetized +IMPORT TABLE foo (id INT8, email STRING, age INT8) CSV DATA (_, $1) WITH comma = _, "nullif" = _, temp = $2 -- literals removed +IMPORT TABLE foo (id INT8, email STRING, age INT8) CSV DATA ('_', $1) WITH comma = '_', "nullif" = '_', temp = $2 -- UNEXPECTED REPARSED AST WITHOUT LITERALS +IMPORT TABLE _ (_ INT8, _ STRING, _ INT8) CSV DATA ('path/to/some/file', $1) WITH _ = ',', _ = 'n/a', _ = $2 -- identifiers removed + +parse +IMPORT TABLE foo FROM PGDUMPCREATE 'nodelocal://0/foo/bar' WITH temp = 'path/to/temp' +---- +IMPORT TABLE foo FROM PGDUMPCREATE 'nodelocal://0/foo/bar' WITH temp = 'path/to/temp' +IMPORT TABLE foo FROM PGDUMPCREATE ('nodelocal://0/foo/bar') WITH temp = ('path/to/temp') -- fully parenthetized +IMPORT TABLE foo FROM PGDUMPCREATE _ WITH temp = _ -- literals removed +IMPORT TABLE foo FROM PGDUMPCREATE '_' WITH temp = '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +IMPORT TABLE _ FROM PGDUMPCREATE 'nodelocal://0/foo/bar' WITH _ = 'path/to/temp' -- identifiers removed + +parse +IMPORT TABLE foo FROM PGDUMPCREATE ('nodelocal://0/foo/bar') WITH temp = 'path/to/temp' +---- +IMPORT TABLE foo FROM PGDUMPCREATE 'nodelocal://0/foo/bar' WITH temp = 'path/to/temp' -- normalized! +IMPORT TABLE foo FROM PGDUMPCREATE ('nodelocal://0/foo/bar') WITH temp = ('path/to/temp') -- fully parenthetized +IMPORT TABLE foo FROM PGDUMPCREATE _ WITH temp = _ -- literals removed +IMPORT TABLE foo FROM PGDUMPCREATE '_' WITH temp = '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +IMPORT TABLE _ FROM PGDUMPCREATE 'nodelocal://0/foo/bar' WITH _ = 'path/to/temp' -- identifiers removed + +parse +IMPORT INTO foo(id, email) CSV DATA ('path/to/some/file', $1) WITH temp = 'path/to/temp' +---- +IMPORT INTO foo(id, email) CSV DATA ('path/to/some/file', $1) WITH temp = 'path/to/temp' +IMPORT INTO foo(id, email) CSV DATA (('path/to/some/file'), ($1)) WITH temp = ('path/to/temp') -- fully parenthetized +IMPORT INTO foo(id, email) CSV DATA (_, $1) WITH temp = _ -- literals removed +IMPORT INTO foo(id, email) CSV DATA ('_', $1) WITH temp = '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +IMPORT INTO _(_, _) CSV DATA ('path/to/some/file', $1) WITH _ = 'path/to/temp' -- identifiers removed + +parse +IMPORT INTO foo CSV DATA ('path/to/some/file', $1) WITH temp = 'path/to/temp' +---- +IMPORT INTO foo CSV DATA ('path/to/some/file', $1) WITH temp = 'path/to/temp' +IMPORT INTO foo CSV DATA (('path/to/some/file'), ($1)) WITH temp = ('path/to/temp') -- fully parenthetized +IMPORT INTO foo CSV DATA (_, $1) WITH temp = _ -- literals removed +IMPORT INTO foo CSV DATA ('_', $1) WITH temp = '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +IMPORT INTO _ CSV DATA ('path/to/some/file', $1) WITH _ = 'path/to/temp' -- identifiers removed + +parse +IMPORT TABLE a.foo (LIKE tab, col INT8 CONSTRAINT conname NULL NOT VISIBLE) CSV DATA ('placeholder') +---- +IMPORT TABLE a.foo (LIKE tab, col INT8 CONSTRAINT conname NULL NOT VISIBLE) CSV DATA ('placeholder') +IMPORT TABLE a.foo (LIKE tab, col INT8 CONSTRAINT conname NULL NOT VISIBLE) CSV DATA (('placeholder')) -- fully parenthetized +IMPORT TABLE a.foo (LIKE tab, col INT8 CONSTRAINT conname NULL NOT VISIBLE) CSV DATA (_) -- literals removed +IMPORT TABLE a.foo (LIKE tab, col INT8 CONSTRAINT conname NULL NOT VISIBLE) CSV DATA ('_') -- UNEXPECTED REPARSED AST WITHOUT LITERALS +IMPORT TABLE _._ (LIKE _, _ INT8 CONSTRAINT _ NULL NOT VISIBLE) CSV DATA ('placeholder') -- identifiers removed + +parse +IMPORT PGDUMP 'nodelocal://0/foo/bar' WITH temp = 'path/to/temp' +---- +IMPORT PGDUMP 'nodelocal://0/foo/bar' WITH temp = 'path/to/temp' +IMPORT PGDUMP ('nodelocal://0/foo/bar') WITH temp = ('path/to/temp') -- fully parenthetized +IMPORT PGDUMP _ WITH temp = _ -- literals removed +IMPORT PGDUMP '_' WITH temp = '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +IMPORT PGDUMP 'nodelocal://0/foo/bar' WITH _ = 'path/to/temp' -- identifiers removed + +parse +EXPLAIN IMPORT PGDUMP 'nodelocal://0/foo/bar' WITH temp = 'path/to/temp' +---- +EXPLAIN IMPORT PGDUMP 'nodelocal://0/foo/bar' WITH temp = 'path/to/temp' +EXPLAIN IMPORT PGDUMP ('nodelocal://0/foo/bar') WITH temp = ('path/to/temp') -- fully parenthetized +EXPLAIN IMPORT PGDUMP _ WITH temp = _ -- literals removed +EXPLAIN IMPORT PGDUMP '_' WITH temp = '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +EXPLAIN IMPORT PGDUMP 'nodelocal://0/foo/bar' WITH _ = 'path/to/temp' -- identifiers removed + +parse +IMPORT PGDUMP ('nodelocal://0/foo/bar') WITH temp = 'path/to/temp' +---- +IMPORT PGDUMP 'nodelocal://0/foo/bar' WITH temp = 'path/to/temp' -- normalized! +IMPORT PGDUMP ('nodelocal://0/foo/bar') WITH temp = ('path/to/temp') -- fully parenthetized +IMPORT PGDUMP _ WITH temp = _ -- literals removed +IMPORT PGDUMP '_' WITH temp = '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +IMPORT PGDUMP 'nodelocal://0/foo/bar' WITH _ = 'path/to/temp' -- identifiers removed + +parse +EXPORT INTO CSV 'a' FROM TABLE a +---- +EXPORT INTO CSV 'a' FROM TABLE a +EXPORT INTO CSV ('a') FROM TABLE a -- fully parenthetized +EXPORT INTO CSV _ FROM TABLE a -- literals removed +EXPORT INTO CSV '_' FROM TABLE a -- UNEXPECTED REPARSED AST WITHOUT LITERALS +EXPORT INTO CSV 'a' FROM TABLE _ -- identifiers removed + +parse +EXPORT INTO CSV 'a' FROM SELECT * FROM a +---- +EXPORT INTO CSV 'a' FROM SELECT * FROM a +EXPORT INTO CSV ('a') FROM SELECT (*) FROM a -- fully parenthetized +EXPORT INTO CSV _ FROM SELECT * FROM a -- literals removed +EXPORT INTO CSV '_' FROM SELECT * FROM a -- UNEXPECTED REPARSED AST WITHOUT LITERALS +EXPORT INTO CSV 'a' FROM SELECT * FROM _ -- identifiers removed + +parse +EXPORT INTO CSV 's3://my/path/%part%.csv' WITH delimiter = '|' FROM TABLE a +---- +EXPORT INTO CSV 's3://my/path/%part%.csv' WITH delimiter = '|' FROM TABLE a +EXPORT INTO CSV ('s3://my/path/%part%.csv') WITH delimiter = ('|') FROM TABLE a -- fully parenthetized +EXPORT INTO CSV _ WITH delimiter = _ FROM TABLE a -- literals removed +EXPORT INTO CSV '_' WITH delimiter = '_' FROM TABLE a -- UNEXPECTED REPARSED AST WITHOUT LITERALS +EXPORT INTO CSV 's3://my/path/%part%.csv' WITH _ = '|' FROM TABLE _ -- identifiers removed + +parse +EXPORT INTO CSV 's3://my/path/%part%.csv' WITH delimiter = '|' FROM SELECT a, sum(b) FROM c WHERE d = 1 ORDER BY sum(b) DESC LIMIT 10 +---- +EXPORT INTO CSV 's3://my/path/%part%.csv' WITH delimiter = '|' FROM SELECT a, sum(b) FROM c WHERE d = 1 ORDER BY sum(b) DESC LIMIT 10 +EXPORT INTO CSV ('s3://my/path/%part%.csv') WITH delimiter = ('|') FROM SELECT (a), ((sum)((b))) FROM c WHERE ((d) = (1)) ORDER BY ((sum)((b))) DESC LIMIT (10) -- fully parenthetized +EXPORT INTO CSV _ WITH delimiter = _ FROM SELECT a, sum(b) FROM c WHERE d = _ ORDER BY sum(b) DESC LIMIT _ -- literals removed +EXPORT INTO CSV '_' WITH delimiter = '_' FROM SELECT a, sum(b) FROM c WHERE d = _ ORDER BY sum(b) DESC LIMIT _ -- UNEXPECTED REPARSED AST WITHOUT LITERALS +EXPORT INTO CSV 's3://my/path/%part%.csv' WITH _ = '|' FROM SELECT _, sum(_) FROM _ WHERE _ = 1 ORDER BY sum(_) DESC LIMIT 10 -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/insert b/pkg/sql/parser/testdata/parse/insert new file mode 100644 index 000000000000..d316cc03abad --- /dev/null +++ b/pkg/sql/parser/testdata/parse/insert @@ -0,0 +1,161 @@ +parse +INSERT INTO a VALUES (1) +---- +INSERT INTO a VALUES (1) +INSERT INTO a VALUES ((1)) -- fully parenthetized +INSERT INTO a VALUES (_) -- literals removed +INSERT INTO _ VALUES (1) -- identifiers removed + +parse +EXPLAIN INSERT INTO a VALUES (1) +---- +EXPLAIN INSERT INTO a VALUES (1) +EXPLAIN INSERT INTO a VALUES ((1)) -- fully parenthetized +EXPLAIN INSERT INTO a VALUES (_) -- literals removed +EXPLAIN INSERT INTO _ VALUES (1) -- identifiers removed + +parse +INSERT INTO a.b VALUES (1) +---- +INSERT INTO a.b VALUES (1) +INSERT INTO a.b VALUES ((1)) -- fully parenthetized +INSERT INTO a.b VALUES (_) -- literals removed +INSERT INTO _._ VALUES (1) -- identifiers removed + +parse +INSERT INTO a VALUES (1, 2) +---- +INSERT INTO a VALUES (1, 2) +INSERT INTO a VALUES ((1), (2)) -- fully parenthetized +INSERT INTO a VALUES (_, _) -- literals removed +INSERT INTO _ VALUES (1, 2) -- identifiers removed + +parse +INSERT INTO a VALUES (1, DEFAULT) +---- +INSERT INTO a VALUES (1, DEFAULT) +INSERT INTO a VALUES ((1), (DEFAULT)) -- fully parenthetized +INSERT INTO a VALUES (_, DEFAULT) -- literals removed +INSERT INTO _ VALUES (1, DEFAULT) -- identifiers removed + +parse +INSERT INTO a VALUES (1, 2), (3, 4) +---- +INSERT INTO a VALUES (1, 2), (3, 4) +INSERT INTO a VALUES ((1), (2)), ((3), (4)) -- fully parenthetized +INSERT INTO a VALUES (_, _), (__more1__) -- literals removed +INSERT INTO _ VALUES (1, 2), (3, 4) -- identifiers removed + +parse +INSERT INTO a VALUES (0), (0), (0), (0), (0), (0) +---- +INSERT INTO a VALUES (0), (0), (0), (0), (0), (0) +INSERT INTO a VALUES ((0)), ((0)), ((0)), ((0)), ((0)), ((0)) -- fully parenthetized +INSERT INTO a VALUES (_), (__more5__) -- literals removed +INSERT INTO _ VALUES (0), (0), (0), (0), (0), (0) -- identifiers removed + +parse +INSERT INTO a VALUES (0, 0, 0, 0, 0, 0) +---- +INSERT INTO a VALUES (0, 0, 0, 0, 0, 0) +INSERT INTO a VALUES ((0), (0), (0), (0), (0), (0)) -- fully parenthetized +INSERT INTO a VALUES (_, _, __more4__) -- literals removed +INSERT INTO _ VALUES (0, 0, 0, 0, 0, 0) -- identifiers removed + +parse +INSERT INTO a VALUES (ARRAY[0, 0, 0, 0, 0, 0, 0]) +---- +INSERT INTO a VALUES (ARRAY[0, 0, 0, 0, 0, 0, 0]) +INSERT INTO a VALUES ((ARRAY[(0), (0), (0), (0), (0), (0), (0)])) -- fully parenthetized +INSERT INTO a VALUES (ARRAY[_, _, __more5__]) -- literals removed +INSERT INTO _ VALUES (ARRAY[0, 0, 0, 0, 0, 0, 0]) -- identifiers removed + +parse +INSERT INTO a VALUES (ARRAY[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) +---- +INSERT INTO a VALUES (ARRAY[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) -- normalized! +INSERT INTO a VALUES ((ARRAY[(0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0)])) -- fully parenthetized +INSERT INTO a VALUES (ARRAY[_, _, __more30__]) -- literals removed +INSERT INTO _ VALUES (ARRAY[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) -- identifiers removed + +parse +INSERT INTO a VALUES (-2, +3) +---- +INSERT INTO a VALUES (-2, 3) -- normalized! +INSERT INTO a VALUES ((-2), (3)) -- fully parenthetized +INSERT INTO a VALUES (_, _) -- literals removed +INSERT INTO _ VALUES (-2, 3) -- identifiers removed + +parse +INSERT INTO a VALUES (a + 1, 2 * 3) +---- +INSERT INTO a VALUES (a + 1, 2 * 3) +INSERT INTO a VALUES (((a) + (1)), ((2) * (3))) -- fully parenthetized +INSERT INTO a VALUES (a + _, _ * _) -- literals removed +INSERT INTO _ VALUES (_ + 1, 2 * 3) -- identifiers removed + +parse +INSERT INTO a(a, b) VALUES (1, 2) +---- +INSERT INTO a(a, b) VALUES (1, 2) +INSERT INTO a(a, b) VALUES ((1), (2)) -- fully parenthetized +INSERT INTO a(a, b) VALUES (_, _) -- literals removed +INSERT INTO _(_, _) VALUES (1, 2) -- identifiers removed + +parse +INSERT INTO foo(x) TABLE bar +---- +INSERT INTO foo(x) TABLE bar +INSERT INTO foo(x) TABLE bar -- fully parenthetized +INSERT INTO foo(x) TABLE bar -- literals removed +INSERT INTO _(_) TABLE _ -- identifiers removed + +parse +INSERT INTO a SELECT b, c FROM d +---- +INSERT INTO a SELECT b, c FROM d +INSERT INTO a SELECT (b), (c) FROM d -- fully parenthetized +INSERT INTO a SELECT b, c FROM d -- literals removed +INSERT INTO _ SELECT _, _ FROM _ -- identifiers removed + +parse +INSERT INTO a DEFAULT VALUES +---- +INSERT INTO a DEFAULT VALUES +INSERT INTO a DEFAULT VALUES -- fully parenthetized +INSERT INTO a DEFAULT VALUES -- literals removed +INSERT INTO _ DEFAULT VALUES -- identifiers removed + +parse +INSERT INTO a VALUES (1) RETURNING a, b +---- +INSERT INTO a VALUES (1) RETURNING a, b +INSERT INTO a VALUES ((1)) RETURNING (a), (b) -- fully parenthetized +INSERT INTO a VALUES (_) RETURNING a, b -- literals removed +INSERT INTO _ VALUES (1) RETURNING _, _ -- identifiers removed + +parse +INSERT INTO a VALUES (1, 2) RETURNING 1, 2 +---- +INSERT INTO a VALUES (1, 2) RETURNING 1, 2 +INSERT INTO a VALUES ((1), (2)) RETURNING (1), (2) -- fully parenthetized +INSERT INTO a VALUES (_, _) RETURNING _, _ -- literals removed +INSERT INTO _ VALUES (1, 2) RETURNING 1, 2 -- identifiers removed + +parse +INSERT INTO a VALUES (1, 2) RETURNING a + b, c +---- +INSERT INTO a VALUES (1, 2) RETURNING a + b, c +INSERT INTO a VALUES ((1), (2)) RETURNING ((a) + (b)), (c) -- fully parenthetized +INSERT INTO a VALUES (_, _) RETURNING a + b, c -- literals removed +INSERT INTO _ VALUES (1, 2) RETURNING _ + _, _ -- identifiers removed + +parse +INSERT INTO a VALUES (1, 2) RETURNING NOTHING +---- +INSERT INTO a VALUES (1, 2) RETURNING NOTHING +INSERT INTO a VALUES ((1), (2)) RETURNING NOTHING -- fully parenthetized +INSERT INTO a VALUES (_, _) RETURNING NOTHING -- literals removed +INSERT INTO _ VALUES (1, 2) RETURNING NOTHING -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/predefined_functions b/pkg/sql/parser/testdata/parse/predefined_functions new file mode 100644 index 000000000000..a50a69ca1c3a --- /dev/null +++ b/pkg/sql/parser/testdata/parse/predefined_functions @@ -0,0 +1,303 @@ +parse +SELECT CURRENT_SCHEMA +---- +SELECT current_schema() -- normalized! +SELECT (current_schema()) -- fully parenthetized +SELECT current_schema() -- literals removed +SELECT current_schema() -- identifiers removed + +parse +SELECT CURRENT_CATALOG +---- +SELECT current_database() -- normalized! +SELECT (current_database()) -- fully parenthetized +SELECT current_database() -- literals removed +SELECT current_database() -- identifiers removed + +parse +SELECT CURRENT_TIMESTAMP +---- +SELECT current_timestamp() -- normalized! +SELECT (current_timestamp()) -- fully parenthetized +SELECT current_timestamp() -- literals removed +SELECT current_timestamp() -- identifiers removed + +parse +SELECT current_timestamp(6) +---- +SELECT current_timestamp(6) +SELECT (current_timestamp((6))) -- fully parenthetized +SELECT current_timestamp(_) -- literals removed +SELECT current_timestamp(6) -- identifiers removed + +parse +SELECT CURRENT_TIME +---- +SELECT current_time() -- normalized! +SELECT (current_time()) -- fully parenthetized +SELECT current_time() -- literals removed +SELECT current_time() -- identifiers removed + +parse +SELECT current_time(6) +---- +SELECT current_time(6) +SELECT (current_time((6))) -- fully parenthetized +SELECT current_time(_) -- literals removed +SELECT current_time(6) -- identifiers removed + +parse +SELECT CURRENT_DATE +---- +SELECT current_date() -- normalized! +SELECT (current_date()) -- fully parenthetized +SELECT current_date() -- literals removed +SELECT current_date() -- identifiers removed + +parse +SELECT POSITION(a IN b) +---- +SELECT strpos(b, a) -- normalized! +SELECT (strpos((b), (a))) -- fully parenthetized +SELECT strpos(b, a) -- literals removed +SELECT strpos(_, _) -- identifiers removed + +parse +SELECT TRIM(BOTH a FROM b) +---- +SELECT btrim(b, a) -- normalized! +SELECT (btrim((b), (a))) -- fully parenthetized +SELECT btrim(b, a) -- literals removed +SELECT btrim(_, _) -- identifiers removed + +parse +SELECT TRIM(LEADING a FROM b) +---- +SELECT ltrim(b, a) -- normalized! +SELECT (ltrim((b), (a))) -- fully parenthetized +SELECT ltrim(b, a) -- literals removed +SELECT ltrim(_, _) -- identifiers removed + +parse +SELECT TRIM(TRAILING a FROM b) +---- +SELECT rtrim(b, a) -- normalized! +SELECT (rtrim((b), (a))) -- fully parenthetized +SELECT rtrim(b, a) -- literals removed +SELECT rtrim(_, _) -- identifiers removed + +parse +SELECT TRIM(a, b) +---- +SELECT btrim(a, b) -- normalized! +SELECT (btrim((a), (b))) -- fully parenthetized +SELECT btrim(a, b) -- literals removed +SELECT btrim(_, _) -- identifiers removed + +parse +SELECT CURRENT_USER +---- +SELECT current_user() -- normalized! +SELECT (current_user()) -- fully parenthetized +SELECT current_user() -- literals removed +SELECT current_user() -- identifiers removed + +parse +SELECT CURRENT_ROLE +---- +SELECT current_user() -- normalized! +SELECT (current_user()) -- fully parenthetized +SELECT current_user() -- literals removed +SELECT current_user() -- identifiers removed + +parse +SELECT SESSION_USER +---- +SELECT current_user() -- normalized! +SELECT (current_user()) -- fully parenthetized +SELECT current_user() -- literals removed +SELECT current_user() -- identifiers removed + +parse +SELECT USER +---- +SELECT current_user() -- normalized! +SELECT (current_user()) -- fully parenthetized +SELECT current_user() -- literals removed +SELECT current_user() -- identifiers removed + +parse +SELECT SUBSTRING('RoacH' from 2 for 3) +---- +SELECT substring('RoacH', 2, 3) -- normalized! +SELECT (substring(('RoacH'), (2), (3))) -- fully parenthetized +SELECT substring(_, _, _) -- literals removed +SELECT substring('RoacH', 2, 3) -- identifiers removed + +parse +SELECT SUBSTRING('RoacH' for 2 from 3) +---- +SELECT substring('RoacH', 3, 2) -- normalized! +SELECT (substring(('RoacH'), (3), (2))) -- fully parenthetized +SELECT substring(_, _, _) -- literals removed +SELECT substring('RoacH', 3, 2) -- identifiers removed + +parse +SELECT SUBSTRING('RoacH' from 2) +---- +SELECT substring('RoacH', 2) -- normalized! +SELECT (substring(('RoacH'), (2))) -- fully parenthetized +SELECT substring(_, _) -- literals removed +SELECT substring('RoacH', 2) -- identifiers removed + +parse +SELECT SUBSTRING('RoacH' for 3) +---- +SELECT substring('RoacH', 1, 3) -- normalized! +SELECT (substring(('RoacH'), (1), (3))) -- fully parenthetized +SELECT substring(_, _, _) -- literals removed +SELECT substring('RoacH', 1, 3) -- identifiers removed + +parse +SELECT SUBSTRING('f(oabaroob' from '\(o(.)b') +---- +SELECT substring('f(oabaroob', e'\\(o(.)b') -- normalized! +SELECT (substring(('f(oabaroob'), (e'\\(o(.)b'))) -- fully parenthetized +SELECT substring(_, _) -- literals removed +SELECT substring('f(oabaroob', e'\\(o(.)b') -- identifiers removed + +parse +SELECT SUBSTRING('f(oabaroob' from '+(o(.)b' for '+') +---- +SELECT substring('f(oabaroob', '+(o(.)b', '+') -- normalized! +SELECT (substring(('f(oabaroob'), ('+(o(.)b'), ('+'))) -- fully parenthetized +SELECT substring(_, _, _) -- literals removed +SELECT substring('f(oabaroob', '+(o(.)b', '+') -- identifiers removed + +parse +SELECT POSITION('ig' in 'high') +---- +SELECT strpos('high', 'ig') -- normalized! +SELECT (strpos(('high'), ('ig'))) -- fully parenthetized +SELECT strpos(_, _) -- literals removed +SELECT strpos('high', 'ig') -- identifiers removed + +parse +SELECT OVERLAY('w33333rce' PLACING 'resou' FROM 3) +---- +SELECT overlay('w33333rce', 'resou', 3) -- normalized! +SELECT (overlay(('w33333rce'), ('resou'), (3))) -- fully parenthetized +SELECT overlay(_, _, _) -- literals removed +SELECT overlay('w33333rce', 'resou', 3) -- identifiers removed + +parse +SELECT OVERLAY('w33333rce' PLACING 'resou' FROM 3 FOR 5) +---- +SELECT overlay('w33333rce', 'resou', 3, 5) -- normalized! +SELECT (overlay(('w33333rce'), ('resou'), (3), (5))) -- fully parenthetized +SELECT overlay(_, _, _, _) -- literals removed +SELECT overlay('w33333rce', 'resou', 3, 5) -- identifiers removed + +parse +SELECT EXTRACT(second from now()) +---- +SELECT extract('second', now()) -- normalized! +SELECT (extract(('second'), ((now)()))) -- fully parenthetized +SELECT extract(_, now()) -- literals removed +SELECT extract('second', now()) -- identifiers removed + +parse +SELECT EXTRACT('second' from now()) +---- +SELECT extract('second', now()) -- normalized! +SELECT (extract(('second'), ((now)()))) -- fully parenthetized +SELECT extract(_, now()) -- literals removed +SELECT extract('second', now()) -- identifiers removed + +parse +SELECT TRIM('xy' from 'xyxtrimyyx') +---- +SELECT btrim('xyxtrimyyx', 'xy') -- normalized! +SELECT (btrim(('xyxtrimyyx'), ('xy'))) -- fully parenthetized +SELECT btrim(_, _) -- literals removed +SELECT btrim('xyxtrimyyx', 'xy') -- identifiers removed + +parse +SELECT TRIM(both 'xy' from 'xyxtrimyyx') +---- +SELECT btrim('xyxtrimyyx', 'xy') -- normalized! +SELECT (btrim(('xyxtrimyyx'), ('xy'))) -- fully parenthetized +SELECT btrim(_, _) -- literals removed +SELECT btrim('xyxtrimyyx', 'xy') -- identifiers removed + +parse +SELECT TRIM(from 'xyxtrimyyx') +---- +SELECT btrim('xyxtrimyyx') -- normalized! +SELECT (btrim(('xyxtrimyyx'))) -- fully parenthetized +SELECT btrim(_) -- literals removed +SELECT btrim('xyxtrimyyx') -- identifiers removed + +parse +SELECT TRIM(both 'xyxtrimyyx') +---- +SELECT btrim('xyxtrimyyx') -- normalized! +SELECT (btrim(('xyxtrimyyx'))) -- fully parenthetized +SELECT btrim(_) -- literals removed +SELECT btrim('xyxtrimyyx') -- identifiers removed + +parse +SELECT TRIM(both from 'xyxtrimyyx') +---- +SELECT btrim('xyxtrimyyx') -- normalized! +SELECT (btrim(('xyxtrimyyx'))) -- fully parenthetized +SELECT btrim(_) -- literals removed +SELECT btrim('xyxtrimyyx') -- identifiers removed + +parse +SELECT TRIM(leading 'xy' from 'xyxtrimyyx') +---- +SELECT ltrim('xyxtrimyyx', 'xy') -- normalized! +SELECT (ltrim(('xyxtrimyyx'), ('xy'))) -- fully parenthetized +SELECT ltrim(_, _) -- literals removed +SELECT ltrim('xyxtrimyyx', 'xy') -- identifiers removed + +parse +SELECT TRIM(leading from 'xyxtrimyyx') +---- +SELECT ltrim('xyxtrimyyx') -- normalized! +SELECT (ltrim(('xyxtrimyyx'))) -- fully parenthetized +SELECT ltrim(_) -- literals removed +SELECT ltrim('xyxtrimyyx') -- identifiers removed + +parse +SELECT TRIM(leading 'xyxtrimyyx') +---- +SELECT ltrim('xyxtrimyyx') -- normalized! +SELECT (ltrim(('xyxtrimyyx'))) -- fully parenthetized +SELECT ltrim(_) -- literals removed +SELECT ltrim('xyxtrimyyx') -- identifiers removed + +parse +SELECT TRIM(trailing 'xy' from 'xyxtrimyyx') +---- +SELECT rtrim('xyxtrimyyx', 'xy') -- normalized! +SELECT (rtrim(('xyxtrimyyx'), ('xy'))) -- fully parenthetized +SELECT rtrim(_, _) -- literals removed +SELECT rtrim('xyxtrimyyx', 'xy') -- identifiers removed + +parse +SELECT TRIM(trailing from 'xyxtrimyyx') +---- +SELECT rtrim('xyxtrimyyx') -- normalized! +SELECT (rtrim(('xyxtrimyyx'))) -- fully parenthetized +SELECT rtrim(_) -- literals removed +SELECT rtrim('xyxtrimyyx') -- identifiers removed + +parse +SELECT TRIM(trailing 'xyxtrimyyx') +---- +SELECT rtrim('xyxtrimyyx') -- normalized! +SELECT (rtrim(('xyxtrimyyx'))) -- fully parenthetized +SELECT rtrim(_) -- literals removed +SELECT rtrim('xyxtrimyyx') -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/prepared_stmts b/pkg/sql/parser/testdata/parse/prepared_stmts new file mode 100644 index 000000000000..f5258a2ed50c --- /dev/null +++ b/pkg/sql/parser/testdata/parse/prepared_stmts @@ -0,0 +1,354 @@ +parse +PREPARE a AS SELECT 1 +---- +PREPARE a AS SELECT 1 +PREPARE a AS SELECT (1) -- fully parenthetized +PREPARE a AS SELECT _ -- literals removed +PREPARE _ AS SELECT 1 -- identifiers removed + +parse +PREPARE a AS EXPLAIN SELECT 1 +---- +PREPARE a AS EXPLAIN SELECT 1 +PREPARE a AS EXPLAIN SELECT (1) -- fully parenthetized +PREPARE a AS EXPLAIN SELECT _ -- literals removed +PREPARE _ AS EXPLAIN SELECT 1 -- identifiers removed + +parse +PREPARE a (INT8) AS SELECT $1 +---- +PREPARE a (INT8) AS SELECT $1 +PREPARE a (INT8) AS SELECT ($1) -- fully parenthetized +PREPARE a (INT8) AS SELECT $1 -- literals removed +PREPARE _ (INT8) AS SELECT $1 -- identifiers removed + +parse +PREPARE a (STRING, STRING) AS SELECT $1, $2 +---- +PREPARE a (STRING, STRING) AS SELECT $1, $2 +PREPARE a (STRING, STRING) AS SELECT ($1), ($2) -- fully parenthetized +PREPARE a (STRING, STRING) AS SELECT $1, $2 -- literals removed +PREPARE _ (STRING, STRING) AS SELECT $1, $2 -- identifiers removed + +parse +PREPARE a AS INSERT INTO a VALUES (1) +---- +PREPARE a AS INSERT INTO a VALUES (1) +PREPARE a AS INSERT INTO a VALUES ((1)) -- fully parenthetized +PREPARE a AS INSERT INTO a VALUES (_) -- literals removed +PREPARE _ AS INSERT INTO _ VALUES (1) -- identifiers removed + +parse +PREPARE a (INT8) AS INSERT INTO a VALUES ($1) +---- +PREPARE a (INT8) AS INSERT INTO a VALUES ($1) +PREPARE a (INT8) AS INSERT INTO a VALUES (($1)) -- fully parenthetized +PREPARE a (INT8) AS INSERT INTO a VALUES ($1) -- literals removed +PREPARE _ (INT8) AS INSERT INTO _ VALUES ($1) -- identifiers removed + +parse +PREPARE a AS UPDATE a SET b = 1 +---- +PREPARE a AS UPDATE a SET b = 1 +PREPARE a AS UPDATE a SET b = (1) -- fully parenthetized +PREPARE a AS UPDATE a SET b = _ -- literals removed +PREPARE _ AS UPDATE _ SET _ = 1 -- identifiers removed + +parse +PREPARE a (INT8) AS UPDATE a SET b = $1 +---- +PREPARE a (INT8) AS UPDATE a SET b = $1 +PREPARE a (INT8) AS UPDATE a SET b = ($1) -- fully parenthetized +PREPARE a (INT8) AS UPDATE a SET b = $1 -- literals removed +PREPARE _ (INT8) AS UPDATE _ SET _ = $1 -- identifiers removed + +parse +PREPARE a AS UPSERT INTO a VALUES (1) +---- +PREPARE a AS UPSERT INTO a VALUES (1) +PREPARE a AS UPSERT INTO a VALUES ((1)) -- fully parenthetized +PREPARE a AS UPSERT INTO a VALUES (_) -- literals removed +PREPARE _ AS UPSERT INTO _ VALUES (1) -- identifiers removed + +parse +PREPARE a (INT8) AS UPSERT INTO a VALUES ($1) +---- +PREPARE a (INT8) AS UPSERT INTO a VALUES ($1) +PREPARE a (INT8) AS UPSERT INTO a VALUES (($1)) -- fully parenthetized +PREPARE a (INT8) AS UPSERT INTO a VALUES ($1) -- literals removed +PREPARE _ (INT8) AS UPSERT INTO _ VALUES ($1) -- identifiers removed + +parse +PREPARE a AS DELETE FROM a +---- +PREPARE a AS DELETE FROM a +PREPARE a AS DELETE FROM a -- fully parenthetized +PREPARE a AS DELETE FROM a -- literals removed +PREPARE _ AS DELETE FROM _ -- identifiers removed + +parse +PREPARE a (INT8) AS DELETE FROM a WHERE b = $1 +---- +PREPARE a (INT8) AS DELETE FROM a WHERE b = $1 +PREPARE a (INT8) AS DELETE FROM a WHERE ((b) = ($1)) -- fully parenthetized +PREPARE a (INT8) AS DELETE FROM a WHERE b = $1 -- literals removed +PREPARE _ (INT8) AS DELETE FROM _ WHERE _ = $1 -- identifiers removed + +parse +PREPARE a AS BACKUP DATABASE a TO 'b' +---- +PREPARE a AS BACKUP DATABASE a TO 'b' +PREPARE a AS BACKUP DATABASE a TO ('b') -- fully parenthetized +PREPARE a AS BACKUP DATABASE a TO _ -- literals removed +PREPARE a AS BACKUP DATABASE a TO '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +PREPARE _ AS BACKUP DATABASE _ TO 'b' -- identifiers removed + +parse +PREPARE a (STRING) AS BACKUP DATABASE a TO $1 +---- +PREPARE a (STRING) AS BACKUP DATABASE a TO $1 +PREPARE a (STRING) AS BACKUP DATABASE a TO ($1) -- fully parenthetized +PREPARE a (STRING) AS BACKUP DATABASE a TO $1 -- literals removed +PREPARE _ (STRING) AS BACKUP DATABASE _ TO $1 -- identifiers removed + +parse +PREPARE a AS RESTORE DATABASE a FROM 'b' +---- +PREPARE a AS RESTORE DATABASE a FROM 'b' +PREPARE a AS RESTORE DATABASE a FROM ('b') -- fully parenthetized +PREPARE a AS RESTORE DATABASE a FROM _ -- literals removed +PREPARE a AS RESTORE DATABASE a FROM '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +PREPARE _ AS RESTORE DATABASE _ FROM 'b' -- identifiers removed + +parse +PREPARE a (STRING) AS RESTORE DATABASE a FROM $1 +---- +PREPARE a (STRING) AS RESTORE DATABASE a FROM $1 +PREPARE a (STRING) AS RESTORE DATABASE a FROM ($1) -- fully parenthetized +PREPARE a (STRING) AS RESTORE DATABASE a FROM $1 -- literals removed +PREPARE _ (STRING) AS RESTORE DATABASE _ FROM $1 -- identifiers removed + +parse +PREPARE a AS CANCEL QUERIES SELECT 1 +---- +PREPARE a AS CANCEL QUERIES SELECT 1 +PREPARE a AS CANCEL QUERIES SELECT (1) -- fully parenthetized +PREPARE a AS CANCEL QUERIES SELECT _ -- literals removed +PREPARE _ AS CANCEL QUERIES SELECT 1 -- identifiers removed + +parse +PREPARE a (STRING) AS CANCEL QUERIES SELECT $1 +---- +PREPARE a (STRING) AS CANCEL QUERIES SELECT $1 +PREPARE a (STRING) AS CANCEL QUERIES SELECT ($1) -- fully parenthetized +PREPARE a (STRING) AS CANCEL QUERIES SELECT $1 -- literals removed +PREPARE _ (STRING) AS CANCEL QUERIES SELECT $1 -- identifiers removed + +parse +PREPARE a AS CANCEL QUERIES IF EXISTS SELECT 1 +---- +PREPARE a AS CANCEL QUERIES IF EXISTS SELECT 1 +PREPARE a AS CANCEL QUERIES IF EXISTS SELECT (1) -- fully parenthetized +PREPARE a AS CANCEL QUERIES IF EXISTS SELECT _ -- literals removed +PREPARE _ AS CANCEL QUERIES IF EXISTS SELECT 1 -- identifiers removed + +parse +PREPARE a (STRING) AS CANCEL QUERIES IF EXISTS SELECT $1 +---- +PREPARE a (STRING) AS CANCEL QUERIES IF EXISTS SELECT $1 +PREPARE a (STRING) AS CANCEL QUERIES IF EXISTS SELECT ($1) -- fully parenthetized +PREPARE a (STRING) AS CANCEL QUERIES IF EXISTS SELECT $1 -- literals removed +PREPARE _ (STRING) AS CANCEL QUERIES IF EXISTS SELECT $1 -- identifiers removed + +parse +PREPARE a AS CANCEL SESSIONS SELECT 1 +---- +PREPARE a AS CANCEL SESSIONS SELECT 1 +PREPARE a AS CANCEL SESSIONS SELECT (1) -- fully parenthetized +PREPARE a AS CANCEL SESSIONS SELECT _ -- literals removed +PREPARE _ AS CANCEL SESSIONS SELECT 1 -- identifiers removed + +parse +PREPARE a (STRING) AS CANCEL SESSIONS SELECT $1 +---- +PREPARE a (STRING) AS CANCEL SESSIONS SELECT $1 +PREPARE a (STRING) AS CANCEL SESSIONS SELECT ($1) -- fully parenthetized +PREPARE a (STRING) AS CANCEL SESSIONS SELECT $1 -- literals removed +PREPARE _ (STRING) AS CANCEL SESSIONS SELECT $1 -- identifiers removed + +parse +PREPARE a AS CANCEL SESSIONS IF EXISTS SELECT 1 +---- +PREPARE a AS CANCEL SESSIONS IF EXISTS SELECT 1 +PREPARE a AS CANCEL SESSIONS IF EXISTS SELECT (1) -- fully parenthetized +PREPARE a AS CANCEL SESSIONS IF EXISTS SELECT _ -- literals removed +PREPARE _ AS CANCEL SESSIONS IF EXISTS SELECT 1 -- identifiers removed + +parse +PREPARE a (STRING) AS CANCEL SESSIONS IF EXISTS SELECT $1 +---- +PREPARE a (STRING) AS CANCEL SESSIONS IF EXISTS SELECT $1 +PREPARE a (STRING) AS CANCEL SESSIONS IF EXISTS SELECT ($1) -- fully parenthetized +PREPARE a (STRING) AS CANCEL SESSIONS IF EXISTS SELECT $1 -- literals removed +PREPARE _ (STRING) AS CANCEL SESSIONS IF EXISTS SELECT $1 -- identifiers removed + +parse +PREPARE a AS CANCEL JOBS SELECT 1 +---- +PREPARE a AS CANCEL JOBS SELECT 1 +PREPARE a AS CANCEL JOBS SELECT (1) -- fully parenthetized +PREPARE a AS CANCEL JOBS SELECT _ -- literals removed +PREPARE _ AS CANCEL JOBS SELECT 1 -- identifiers removed + +parse +PREPARE a (INT8) AS CANCEL JOBS SELECT $1 +---- +PREPARE a (INT8) AS CANCEL JOBS SELECT $1 +PREPARE a (INT8) AS CANCEL JOBS SELECT ($1) -- fully parenthetized +PREPARE a (INT8) AS CANCEL JOBS SELECT $1 -- literals removed +PREPARE _ (INT8) AS CANCEL JOBS SELECT $1 -- identifiers removed + +parse +PREPARE a AS PAUSE JOBS SELECT 1 +---- +PREPARE a AS PAUSE JOBS SELECT 1 +PREPARE a AS PAUSE JOBS SELECT (1) -- fully parenthetized +PREPARE a AS PAUSE JOBS SELECT _ -- literals removed +PREPARE _ AS PAUSE JOBS SELECT 1 -- identifiers removed + +parse +PREPARE a (INT8) AS PAUSE JOBS SELECT $1 +---- +PREPARE a (INT8) AS PAUSE JOBS SELECT $1 +PREPARE a (INT8) AS PAUSE JOBS SELECT ($1) -- fully parenthetized +PREPARE a (INT8) AS PAUSE JOBS SELECT $1 -- literals removed +PREPARE _ (INT8) AS PAUSE JOBS SELECT $1 -- identifiers removed + +parse +PREPARE a AS RESUME JOBS SELECT 1 +---- +PREPARE a AS RESUME JOBS SELECT 1 +PREPARE a AS RESUME JOBS SELECT (1) -- fully parenthetized +PREPARE a AS RESUME JOBS SELECT _ -- literals removed +PREPARE _ AS RESUME JOBS SELECT 1 -- identifiers removed + +parse +PREPARE a (INT8) AS RESUME JOBS SELECT $1 +---- +PREPARE a (INT8) AS RESUME JOBS SELECT $1 +PREPARE a (INT8) AS RESUME JOBS SELECT ($1) -- fully parenthetized +PREPARE a (INT8) AS RESUME JOBS SELECT $1 -- literals removed +PREPARE _ (INT8) AS RESUME JOBS SELECT $1 -- identifiers removed + +parse +PREPARE a AS IMPORT TABLE a CREATE USING 'b' CSV DATA ('c') WITH temp = 'd' +---- +PREPARE a AS IMPORT TABLE a CREATE USING 'b' CSV DATA ('c') WITH temp = 'd' +PREPARE a AS IMPORT TABLE a CREATE USING ('b') CSV DATA (('c')) WITH temp = ('d') -- fully parenthetized +PREPARE a AS IMPORT TABLE a CREATE USING _ CSV DATA (_) WITH temp = _ -- literals removed +PREPARE a AS IMPORT TABLE a CREATE USING '_' CSV DATA ('_') WITH temp = '_' -- UNEXPECTED REPARSED AST WITHOUT LITERALS +PREPARE _ AS IMPORT TABLE _ CREATE USING 'b' CSV DATA ('c') WITH _ = 'd' -- identifiers removed + +parse +PREPARE a (STRING, STRING, STRING) AS IMPORT TABLE a CREATE USING $1 CSV DATA ($2) WITH temp = $3 +---- +PREPARE a (STRING, STRING, STRING) AS IMPORT TABLE a CREATE USING $1 CSV DATA ($2) WITH temp = $3 +PREPARE a (STRING, STRING, STRING) AS IMPORT TABLE a CREATE USING ($1) CSV DATA (($2)) WITH temp = ($3) -- fully parenthetized +PREPARE a (STRING, STRING, STRING) AS IMPORT TABLE a CREATE USING $1 CSV DATA ($2) WITH temp = $3 -- literals removed +PREPARE _ (STRING, STRING, STRING) AS IMPORT TABLE _ CREATE USING $1 CSV DATA ($2) WITH _ = $3 -- identifiers removed + +parse +PREPARE a AS OPT PLAN 'some-string' +---- +PREPARE a AS OPT PLAN 'some-string' +PREPARE a AS OPT PLAN 'some-string' -- fully parenthetized +PREPARE a AS OPT PLAN 'some-string' -- literals removed +PREPARE _ AS OPT PLAN 'some-string' -- identifiers removed + +parse +PREPARE a (STRING, INT8) AS OPT PLAN 'some-string' +---- +PREPARE a (STRING, INT8) AS OPT PLAN 'some-string' +PREPARE a (STRING, INT8) AS OPT PLAN 'some-string' -- fully parenthetized +PREPARE a (STRING, INT8) AS OPT PLAN 'some-string' -- literals removed +PREPARE _ (STRING, INT8) AS OPT PLAN 'some-string' -- identifiers removed + +parse +EXECUTE a +---- +EXECUTE a +EXECUTE a -- fully parenthetized +EXECUTE a -- literals removed +EXECUTE _ -- identifiers removed + +parse +EXECUTE a DISCARD ROWS +---- +EXECUTE a DISCARD ROWS +EXECUTE a DISCARD ROWS -- fully parenthetized +EXECUTE a DISCARD ROWS -- literals removed +EXECUTE _ DISCARD ROWS -- identifiers removed + +parse +EXECUTE a (1) +---- +EXECUTE a (1) +EXECUTE a ((1)) -- fully parenthetized +EXECUTE a (_) -- literals removed +EXECUTE _ (1) -- identifiers removed + +parse +EXECUTE a (1, 1) +---- +EXECUTE a (1, 1) +EXECUTE a ((1), (1)) -- fully parenthetized +EXECUTE a (_, _) -- literals removed +EXECUTE _ (1, 1) -- identifiers removed + +parse +EXECUTE a (1, 1) DISCARD ROWS +---- +EXECUTE a (1, 1) DISCARD ROWS +EXECUTE a ((1), (1)) DISCARD ROWS -- fully parenthetized +EXECUTE a (_, _) DISCARD ROWS -- literals removed +EXECUTE _ (1, 1) DISCARD ROWS -- identifiers removed + +parse +EXECUTE a (1 + 1) +---- +EXECUTE a (1 + 1) +EXECUTE a (((1) + (1))) -- fully parenthetized +EXECUTE a (_ + _) -- literals removed +EXECUTE _ (1 + 1) -- identifiers removed + +parse +DEALLOCATE a +---- +DEALLOCATE a +DEALLOCATE a -- fully parenthetized +DEALLOCATE a -- literals removed +DEALLOCATE _ -- identifiers removed + +parse +DEALLOCATE ALL +---- +DEALLOCATE ALL +DEALLOCATE ALL -- fully parenthetized +DEALLOCATE ALL -- literals removed +DEALLOCATE ALL -- identifiers removed + +parse +DEALLOCATE PREPARE a +---- +DEALLOCATE a -- normalized! +DEALLOCATE a -- fully parenthetized +DEALLOCATE a -- literals removed +DEALLOCATE _ -- identifiers removed + +parse +DEALLOCATE PREPARE ALL +---- +DEALLOCATE ALL -- normalized! +DEALLOCATE ALL -- fully parenthetized +DEALLOCATE ALL -- literals removed +DEALLOCATE ALL -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/reassign b/pkg/sql/parser/testdata/parse/reassign new file mode 100644 index 000000000000..3a826c0094ce --- /dev/null +++ b/pkg/sql/parser/testdata/parse/reassign @@ -0,0 +1,81 @@ + +parse +REASSIGN OWNED BY foo TO bar +---- +REASSIGN OWNED BY foo TO bar +REASSIGN OWNED BY foo TO bar -- fully parenthetized +REASSIGN OWNED BY foo TO bar -- literals removed +REASSIGN OWNED BY _ TO _ -- identifiers removed + +parse +REASSIGN OWNED BY foo, bar TO third +---- +REASSIGN OWNED BY foo, bar TO third +REASSIGN OWNED BY foo, bar TO third -- fully parenthetized +REASSIGN OWNED BY foo, bar TO third -- literals removed +REASSIGN OWNED BY _, _ TO _ -- identifiers removed + +parse +REASSIGN OWNED BY CURRENT_USER TO foo +---- +REASSIGN OWNED BY "current_user" TO foo -- normalized! +REASSIGN OWNED BY "current_user" TO foo -- fully parenthetized +REASSIGN OWNED BY "current_user" TO foo -- literals removed +REASSIGN OWNED BY _ TO _ -- identifiers removed + +parse +REASSIGN OWNED BY SESSION_USER TO foo +---- +REASSIGN OWNED BY "session_user" TO foo -- normalized! +REASSIGN OWNED BY "session_user" TO foo -- fully parenthetized +REASSIGN OWNED BY "session_user" TO foo -- literals removed +REASSIGN OWNED BY _ TO _ -- identifiers removed + + +parse +DROP OWNED BY foo +---- +DROP OWNED BY foo +DROP OWNED BY foo -- fully parenthetized +DROP OWNED BY foo -- literals removed +DROP OWNED BY _ -- identifiers removed + +parse +DROP OWNED BY foo, bar +---- +DROP OWNED BY foo, bar +DROP OWNED BY foo, bar -- fully parenthetized +DROP OWNED BY foo, bar -- literals removed +DROP OWNED BY _, _ -- identifiers removed + +parse +DROP OWNED BY foo CASCADE +---- +DROP OWNED BY foo CASCADE +DROP OWNED BY foo CASCADE -- fully parenthetized +DROP OWNED BY foo CASCADE -- literals removed +DROP OWNED BY _ CASCADE -- identifiers removed + +parse +DROP OWNED BY foo RESTRICT +---- +DROP OWNED BY foo RESTRICT +DROP OWNED BY foo RESTRICT -- fully parenthetized +DROP OWNED BY foo RESTRICT -- literals removed +DROP OWNED BY _ RESTRICT -- identifiers removed + +parse +DROP OWNED BY CURRENT_USER +---- +DROP OWNED BY "current_user" -- normalized! +DROP OWNED BY "current_user" -- fully parenthetized +DROP OWNED BY "current_user" -- literals removed +DROP OWNED BY _ -- identifiers removed + +parse +DROP OWNED BY SESSION_USER +---- +DROP OWNED BY "session_user" -- normalized! +DROP OWNED BY "session_user" -- fully parenthetized +DROP OWNED BY "session_user" -- literals removed +DROP OWNED BY _ -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/scrub b/pkg/sql/parser/testdata/parse/scrub new file mode 100644 index 000000000000..e42cae89d6d6 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/scrub @@ -0,0 +1,104 @@ + +parse +EXPERIMENTAL SCRUB DATABASE x +---- +EXPERIMENTAL SCRUB DATABASE x +EXPERIMENTAL SCRUB DATABASE x -- fully parenthetized +EXPERIMENTAL SCRUB DATABASE x -- literals removed +EXPERIMENTAL SCRUB DATABASE _ -- identifiers removed + +parse +EXPLAIN EXPERIMENTAL SCRUB DATABASE x +---- +EXPLAIN EXPERIMENTAL SCRUB DATABASE x +EXPLAIN EXPERIMENTAL SCRUB DATABASE x -- fully parenthetized +EXPLAIN EXPERIMENTAL SCRUB DATABASE x -- literals removed +EXPLAIN EXPERIMENTAL SCRUB DATABASE _ -- identifiers removed + +parse +EXPERIMENTAL SCRUB DATABASE x AS OF SYSTEM TIME 1 +---- +EXPERIMENTAL SCRUB DATABASE x AS OF SYSTEM TIME 1 +EXPERIMENTAL SCRUB DATABASE x AS OF SYSTEM TIME (1) -- fully parenthetized +EXPERIMENTAL SCRUB DATABASE x AS OF SYSTEM TIME _ -- literals removed +EXPERIMENTAL SCRUB DATABASE _ AS OF SYSTEM TIME 1 -- identifiers removed + +parse +EXPERIMENTAL SCRUB TABLE x +---- +EXPERIMENTAL SCRUB TABLE x +EXPERIMENTAL SCRUB TABLE x -- fully parenthetized +EXPERIMENTAL SCRUB TABLE x -- literals removed +EXPERIMENTAL SCRUB TABLE _ -- identifiers removed + +parse +EXPLAIN EXPERIMENTAL SCRUB TABLE x +---- +EXPLAIN EXPERIMENTAL SCRUB TABLE x +EXPLAIN EXPERIMENTAL SCRUB TABLE x -- fully parenthetized +EXPLAIN EXPERIMENTAL SCRUB TABLE x -- literals removed +EXPLAIN EXPERIMENTAL SCRUB TABLE _ -- identifiers removed + +parse +EXPERIMENTAL SCRUB TABLE x AS OF SYSTEM TIME 1 +---- +EXPERIMENTAL SCRUB TABLE x AS OF SYSTEM TIME 1 +EXPERIMENTAL SCRUB TABLE x AS OF SYSTEM TIME (1) -- fully parenthetized +EXPERIMENTAL SCRUB TABLE x AS OF SYSTEM TIME _ -- literals removed +EXPERIMENTAL SCRUB TABLE _ AS OF SYSTEM TIME 1 -- identifiers removed + +parse +EXPERIMENTAL SCRUB TABLE x AS OF SYSTEM TIME 1 WITH OPTIONS INDEX ALL +---- +EXPERIMENTAL SCRUB TABLE x AS OF SYSTEM TIME 1 WITH OPTIONS INDEX ALL +EXPERIMENTAL SCRUB TABLE x AS OF SYSTEM TIME (1) WITH OPTIONS INDEX ALL -- fully parenthetized +EXPERIMENTAL SCRUB TABLE x AS OF SYSTEM TIME _ WITH OPTIONS INDEX ALL -- literals removed +EXPERIMENTAL SCRUB TABLE _ AS OF SYSTEM TIME 1 WITH OPTIONS INDEX ALL -- identifiers removed + +parse +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS INDEX (index_name) +---- +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS INDEX (index_name) +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS INDEX (index_name) -- fully parenthetized +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS INDEX (index_name) -- literals removed +EXPERIMENTAL SCRUB TABLE _ WITH OPTIONS INDEX (_) -- identifiers removed + +parse +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS PHYSICAL +---- +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS PHYSICAL +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS PHYSICAL -- fully parenthetized +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS PHYSICAL -- literals removed +EXPERIMENTAL SCRUB TABLE _ WITH OPTIONS PHYSICAL -- identifiers removed + +parse +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS CONSTRAINT ALL +---- +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS CONSTRAINT ALL +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS CONSTRAINT ALL -- fully parenthetized +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS CONSTRAINT ALL -- literals removed +EXPERIMENTAL SCRUB TABLE _ WITH OPTIONS CONSTRAINT ALL -- identifiers removed + +parse +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS CONSTRAINT (cst_name) +---- +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS CONSTRAINT (cst_name) +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS CONSTRAINT (cst_name) -- fully parenthetized +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS CONSTRAINT (cst_name) -- literals removed +EXPERIMENTAL SCRUB TABLE _ WITH OPTIONS CONSTRAINT (_) -- identifiers removed + +parse +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS PHYSICAL, INDEX (index_name), CONSTRAINT (cst_name) +---- +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS PHYSICAL, INDEX (index_name), CONSTRAINT (cst_name) +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS PHYSICAL, INDEX (index_name), CONSTRAINT (cst_name) -- fully parenthetized +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS PHYSICAL, INDEX (index_name), CONSTRAINT (cst_name) -- literals removed +EXPERIMENTAL SCRUB TABLE _ WITH OPTIONS PHYSICAL, INDEX (_), CONSTRAINT (_) -- identifiers removed + +parse +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS PHYSICAL, INDEX ALL, CONSTRAINT ALL +---- +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS PHYSICAL, INDEX ALL, CONSTRAINT ALL +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS PHYSICAL, INDEX ALL, CONSTRAINT ALL -- fully parenthetized +EXPERIMENTAL SCRUB TABLE x WITH OPTIONS PHYSICAL, INDEX ALL, CONSTRAINT ALL -- literals removed +EXPERIMENTAL SCRUB TABLE _ WITH OPTIONS PHYSICAL, INDEX ALL, CONSTRAINT ALL -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/select_clauses b/pkg/sql/parser/testdata/parse/select_clauses new file mode 100644 index 000000000000..aa0104622eba --- /dev/null +++ b/pkg/sql/parser/testdata/parse/select_clauses @@ -0,0 +1,2761 @@ +## Escaping may change since the scanning process loses information +## (you can write e'\'' or ''''), but these are the idempotent cases. +## Generally, anything that needs to escape plus \ and ' leads to an +## escaped string. + +# This test checks support for comments. +parse +SELECT 1 FROM t -- hello world +---- +SELECT 1 FROM t -- normalized! +SELECT (1) FROM t -- fully parenthetized +SELECT _ FROM t -- literals removed +SELECT 1 FROM _ -- identifiers removed + +parse +SELECT /* hello world */ 1 FROM t +---- +SELECT 1 FROM t -- normalized! +SELECT (1) FROM t -- fully parenthetized +SELECT _ FROM t -- literals removed +SELECT 1 FROM _ -- identifiers removed + +parse +SELECT /* hello */ 1 FROM /* world */ t +---- +SELECT 1 FROM t -- normalized! +SELECT (1) FROM t -- fully parenthetized +SELECT _ FROM t -- literals removed +SELECT 1 FROM _ -- identifiers removed + +parse +SELECT e'a\'a' FROM t +---- +SELECT e'a\'a' FROM t +SELECT (e'a\'a') FROM t -- fully parenthetized +SELECT _ FROM t -- literals removed +SELECT e'a\'a' FROM _ -- identifiers removed + +parse +SELECT e'a\\\\na' FROM t +---- +SELECT e'a\\\\na' FROM t +SELECT (e'a\\\\na') FROM t -- fully parenthetized +SELECT _ FROM t -- literals removed +SELECT e'a\\\\na' FROM _ -- identifiers removed + +parse +SELECT e'\\\\n' FROM t +---- +SELECT e'\\\\n' FROM t +SELECT (e'\\\\n') FROM t -- fully parenthetized +SELECT _ FROM t -- literals removed +SELECT e'\\\\n' FROM _ -- identifiers removed + +parse +SELECT "a""a" FROM t +---- +SELECT "a""a" FROM t +SELECT ("a""a") FROM t -- fully parenthetized +SELECT "a""a" FROM t -- literals removed +SELECT _ FROM _ -- identifiers removed + +parse +SELECT a FROM "t\n" -- no escaping in sql identifiers +---- +SELECT a FROM "t\n" -- normalized! +SELECT (a) FROM "t\n" -- fully parenthetized +SELECT a FROM "t\n" -- literals removed +SELECT _ FROM _ -- identifiers removed + +parse +SELECT a FROM "t""" -- no escaping in sql identifiers +---- +SELECT a FROM "t""" -- normalized! +SELECT (a) FROM "t""" -- fully parenthetized +SELECT a FROM "t""" -- literals removed +SELECT _ FROM _ -- identifiers removed + +parse +SELECT "full" FROM t -- must quote column name keyword +---- +SELECT "full" FROM t -- normalized! +SELECT ("full") FROM t -- fully parenthetized +SELECT "full" FROM t -- literals removed +SELECT _ FROM _ -- identifiers removed + +parse +SELECT "FROM" FROM t +---- +SELECT "FROM" FROM t +SELECT ("FROM") FROM t -- fully parenthetized +SELECT "FROM" FROM t -- literals removed +SELECT _ FROM _ -- identifiers removed + +parse +SELECT 1 FROM t +---- +SELECT 1 FROM t +SELECT (1) FROM t -- fully parenthetized +SELECT _ FROM t -- literals removed +SELECT 1 FROM _ -- identifiers removed + +parse +SELECT 1, 2 FROM t +---- +SELECT 1, 2 FROM t +SELECT (1), (2) FROM t -- fully parenthetized +SELECT _, _ FROM t -- literals removed +SELECT 1, 2 FROM _ -- identifiers removed + +parse +SELECT * FROM t +---- +SELECT * FROM t +SELECT (*) FROM t -- fully parenthetized +SELECT * FROM t -- literals removed +SELECT * FROM _ -- identifiers removed + +parse +SELECT "*" FROM t +---- +SELECT "*" FROM t +SELECT ("*") FROM t -- fully parenthetized +SELECT "*" FROM t -- literals removed +SELECT _ FROM _ -- identifiers removed + +parse +SELECT "a'a" FROM t +---- +SELECT "a'a" FROM t +SELECT ("a'a") FROM t -- fully parenthetized +SELECT "a'a" FROM t -- literals removed +SELECT _ FROM _ -- identifiers removed + + +parse +SELECT a, b FROM t +---- +SELECT a, b FROM t +SELECT (a), (b) FROM t -- fully parenthetized +SELECT a, b FROM t -- literals removed +SELECT _, _ FROM _ -- identifiers removed + +parse +SELECT a AS b FROM t +---- +SELECT a AS b FROM t +SELECT (a) AS b FROM t -- fully parenthetized +SELECT a AS b FROM t -- literals removed +SELECT _ AS _ FROM _ -- identifiers removed + +parse +SELECT 1 FROM t t1 +---- +SELECT 1 FROM t AS t1 -- normalized! +SELECT (1) FROM t AS t1 -- fully parenthetized +SELECT _ FROM t AS t1 -- literals removed +SELECT 1 FROM _ AS _ -- identifiers removed + +parse +SELECT 1 FROM t t1 (c1, c2) +---- +SELECT 1 FROM t AS t1 (c1, c2) -- normalized! +SELECT (1) FROM t AS t1 (c1, c2) -- fully parenthetized +SELECT _ FROM t AS t1 (c1, c2) -- literals removed +SELECT 1 FROM _ AS _ (_, _) -- identifiers removed + + +parse +SELECT a.* FROM t +---- +SELECT a.* FROM t +SELECT (a.*) FROM t -- fully parenthetized +SELECT a.* FROM t -- literals removed +SELECT _.* FROM _ -- identifiers removed + +parse +SELECT a = b FROM t +---- +SELECT a = b FROM t +SELECT ((a) = (b)) FROM t -- fully parenthetized +SELECT a = b FROM t -- literals removed +SELECT _ = _ FROM _ -- identifiers removed + +parse +SELECT $1 FROM t +---- +SELECT $1 FROM t +SELECT ($1) FROM t -- fully parenthetized +SELECT $1 FROM t -- literals removed +SELECT $1 FROM _ -- identifiers removed + +parse +SELECT $1, $2 FROM t +---- +SELECT $1, $2 FROM t +SELECT ($1), ($2) FROM t -- fully parenthetized +SELECT $1, $2 FROM t -- literals removed +SELECT $1, $2 FROM _ -- identifiers removed + +parse +SELECT NULL FROM t +---- +SELECT NULL FROM t +SELECT (NULL) FROM t -- fully parenthetized +SELECT _ FROM t -- literals removed +SELECT NULL FROM _ -- identifiers removed + +parse +SELECT 0.1 FROM t +---- +SELECT 0.1 FROM t +SELECT (0.1) FROM t -- fully parenthetized +SELECT _ FROM t -- literals removed +SELECT 0.1 FROM _ -- identifiers removed + +parse +SELECT a FROM t +---- +SELECT a FROM t +SELECT (a) FROM t -- fully parenthetized +SELECT a FROM t -- literals removed +SELECT _ FROM _ -- identifiers removed + +parse +SELECT a.b FROM t +---- +SELECT a.b FROM t +SELECT (a.b) FROM t -- fully parenthetized +SELECT a.b FROM t -- literals removed +SELECT _._ FROM _ -- identifiers removed + +parse +SELECT a.b.* FROM t +---- +SELECT a.b.* FROM t +SELECT (a.b.*) FROM t -- fully parenthetized +SELECT a.b.* FROM t -- literals removed +SELECT _._.* FROM _ -- identifiers removed + +parse +SELECT a.b[1] FROM t +---- +SELECT a.b[1] FROM t +SELECT ((a.b)[(1)]) FROM t -- fully parenthetized +SELECT a.b[_] FROM t -- literals removed +SELECT _._[1] FROM _ -- identifiers removed + +parse +SELECT a.b[1 + 1:4][3] FROM t +---- +SELECT a.b[1 + 1:4][3] FROM t +SELECT ((a.b)[((1) + (1)):(4)][(3)]) FROM t -- fully parenthetized +SELECT a.b[_ + _:_][_] FROM t -- literals removed +SELECT _._[1 + 1:4][3] FROM _ -- identifiers removed + +parse +SELECT a.b[:4][3] FROM t +---- +SELECT a.b[:4][3] FROM t +SELECT ((a.b)[:(4)][(3)]) FROM t -- fully parenthetized +SELECT a.b[:_][_] FROM t -- literals removed +SELECT _._[:4][3] FROM _ -- identifiers removed + +parse +SELECT a.b[1 + 1:][3] FROM t +---- +SELECT a.b[1 + 1:][3] FROM t +SELECT ((a.b)[((1) + (1)):][(3)]) FROM t -- fully parenthetized +SELECT a.b[_ + _:][_] FROM t -- literals removed +SELECT _._[1 + 1:][3] FROM _ -- identifiers removed + +parse +SELECT a.b[:][3] FROM t +---- +SELECT a.b[:][3] FROM t +SELECT ((a.b)[:][(3)]) FROM t -- fully parenthetized +SELECT a.b[:][_] FROM t -- literals removed +SELECT _._[:][3] FROM _ -- identifiers removed + +parse +SELECT 'a' FROM t +---- +SELECT 'a' FROM t +SELECT ('a') FROM t -- fully parenthetized +SELECT _ FROM t -- literals removed +SELECT 'a' FROM _ -- identifiers removed + +parse +SELECT 'a' FROM t@bar +---- +SELECT 'a' FROM t@bar +SELECT ('a') FROM t@bar -- fully parenthetized +SELECT _ FROM t@bar -- literals removed +SELECT 'a' FROM _@_ -- identifiers removed + +parse +SELECT 'a' FROM t@primary +---- +SELECT 'a' FROM t@primary +SELECT ('a') FROM t@primary -- fully parenthetized +SELECT _ FROM t@primary -- literals removed +SELECT 'a' FROM _@_ -- identifiers removed + +parse +SELECT 'a' FROM t@like +---- +SELECT 'a' FROM t@like +SELECT ('a') FROM t@like -- fully parenthetized +SELECT _ FROM t@like -- literals removed +SELECT 'a' FROM _@_ -- identifiers removed + +parse +SELECT 'a' FROM t@{NO_INDEX_JOIN} +---- +SELECT 'a' FROM t@{NO_INDEX_JOIN} +SELECT ('a') FROM t@{NO_INDEX_JOIN} -- fully parenthetized +SELECT _ FROM t@{NO_INDEX_JOIN} -- literals removed +SELECT 'a' FROM _@{NO_INDEX_JOIN} -- identifiers removed + +parse +SELECT 'a' FROM t@{IGNORE_FOREIGN_KEYS} +---- +SELECT 'a' FROM t@{IGNORE_FOREIGN_KEYS} +SELECT ('a') FROM t@{IGNORE_FOREIGN_KEYS} -- fully parenthetized +SELECT _ FROM t@{IGNORE_FOREIGN_KEYS} -- literals removed +SELECT 'a' FROM _@{IGNORE_FOREIGN_KEYS} -- identifiers removed + +parse +SELECT 'a' FROM t@{FORCE_INDEX=idx,ASC} +---- +SELECT 'a' FROM t@{FORCE_INDEX=idx,ASC} +SELECT ('a') FROM t@{FORCE_INDEX=idx,ASC} -- fully parenthetized +SELECT _ FROM t@{FORCE_INDEX=idx,ASC} -- literals removed +SELECT 'a' FROM _@{FORCE_INDEX=_,ASC} -- identifiers removed + +parse +SELECT 'a' FROM t@{FORCE_INDEX=idx,DESC,IGNORE_FOREIGN_KEYS} +---- +SELECT 'a' FROM t@{FORCE_INDEX=idx,DESC,IGNORE_FOREIGN_KEYS} +SELECT ('a') FROM t@{FORCE_INDEX=idx,DESC,IGNORE_FOREIGN_KEYS} -- fully parenthetized +SELECT _ FROM t@{FORCE_INDEX=idx,DESC,IGNORE_FOREIGN_KEYS} -- literals removed +SELECT 'a' FROM _@{FORCE_INDEX=_,DESC,IGNORE_FOREIGN_KEYS} -- identifiers removed + +parse +SELECT * FROM t AS "of" AS OF SYSTEM TIME '2016-01-01' +---- +SELECT * FROM t AS "of" AS OF SYSTEM TIME '2016-01-01' +SELECT (*) FROM t AS "of" AS OF SYSTEM TIME ('2016-01-01') -- fully parenthetized +SELECT * FROM t AS "of" AS OF SYSTEM TIME _ -- literals removed +SELECT * FROM _ AS _ AS OF SYSTEM TIME '2016-01-01' -- identifiers removed + +parse +SELECT a FROM t WHERE a <> b +---- +SELECT a FROM t WHERE a != b -- normalized! +SELECT (a) FROM t WHERE ((a) != (b)) -- fully parenthetized +SELECT a FROM t WHERE a != b -- literals removed +SELECT _ FROM _ WHERE _ != _ -- identifiers removed + +parse +SELECT a FROM t WHERE b = - 2 +---- +SELECT a FROM t WHERE b = -2 -- normalized! +SELECT (a) FROM t WHERE ((b) = (-2)) -- fully parenthetized +SELECT a FROM t WHERE b = _ -- literals removed +SELECT _ FROM _ WHERE _ = -2 -- identifiers removed + +parse +SELECT a FROM t WHERE a = b AND a = c +---- +SELECT a FROM t WHERE (a = b) AND (a = c) -- normalized! +SELECT (a) FROM t WHERE ((((a) = (b))) AND (((a) = (c)))) -- fully parenthetized +SELECT a FROM t WHERE (a = b) AND (a = c) -- literals removed +SELECT _ FROM _ WHERE (_ = _) AND (_ = _) -- identifiers removed + +parse +SELECT a FROM t WHERE a = b OR a = c +---- +SELECT a FROM t WHERE (a = b) OR (a = c) -- normalized! +SELECT (a) FROM t WHERE ((((a) = (b))) OR (((a) = (c)))) -- fully parenthetized +SELECT a FROM t WHERE (a = b) OR (a = c) -- literals removed +SELECT _ FROM _ WHERE (_ = _) OR (_ = _) -- identifiers removed + +parse +SELECT a FROM t WHERE NOT a = b +---- +SELECT a FROM t WHERE NOT (a = b) -- normalized! +SELECT (a) FROM t WHERE (NOT (((a) = (b)))) -- fully parenthetized +SELECT a FROM t WHERE NOT (a = b) -- literals removed +SELECT _ FROM _ WHERE NOT (_ = _) -- identifiers removed + +parse +SELECT a FROM t WHERE a = b & c +---- +SELECT a FROM t WHERE a = (b & c) -- normalized! +SELECT (a) FROM t WHERE ((a) = (((b) & (c)))) -- fully parenthetized +SELECT a FROM t WHERE a = (b & c) -- literals removed +SELECT _ FROM _ WHERE _ = (_ & _) -- identifiers removed + +parse +SELECT a FROM t WHERE a = b | c +---- +SELECT a FROM t WHERE a = (b | c) -- normalized! +SELECT (a) FROM t WHERE ((a) = (((b) | (c)))) -- fully parenthetized +SELECT a FROM t WHERE a = (b | c) -- literals removed +SELECT _ FROM _ WHERE _ = (_ | _) -- identifiers removed + +parse +SELECT a FROM t WHERE a = b # c +---- +SELECT a FROM t WHERE a = (b # c) -- normalized! +SELECT (a) FROM t WHERE ((a) = (((b) # (c)))) -- fully parenthetized +SELECT a FROM t WHERE a = (b # c) -- literals removed +SELECT _ FROM _ WHERE _ = (_ # _) -- identifiers removed + +parse +SELECT a FROM t WHERE a = b ^ c +---- +SELECT a FROM t WHERE a = (b ^ c) -- normalized! +SELECT (a) FROM t WHERE ((a) = (((b) ^ (c)))) -- fully parenthetized +SELECT a FROM t WHERE a = (b ^ c) -- literals removed +SELECT _ FROM _ WHERE _ = (_ ^ _) -- identifiers removed + +parse +SELECT a FROM t WHERE a = b + c +---- +SELECT a FROM t WHERE a = (b + c) -- normalized! +SELECT (a) FROM t WHERE ((a) = (((b) + (c)))) -- fully parenthetized +SELECT a FROM t WHERE a = (b + c) -- literals removed +SELECT _ FROM _ WHERE _ = (_ + _) -- identifiers removed + +parse +SELECT a FROM t WHERE a = b - c +---- +SELECT a FROM t WHERE a = (b - c) -- normalized! +SELECT (a) FROM t WHERE ((a) = (((b) - (c)))) -- fully parenthetized +SELECT a FROM t WHERE a = (b - c) -- literals removed +SELECT _ FROM _ WHERE _ = (_ - _) -- identifiers removed + +parse +SELECT a FROM t WHERE a = b * c +---- +SELECT a FROM t WHERE a = (b * c) -- normalized! +SELECT (a) FROM t WHERE ((a) = (((b) * (c)))) -- fully parenthetized +SELECT a FROM t WHERE a = (b * c) -- literals removed +SELECT _ FROM _ WHERE _ = (_ * _) -- identifiers removed + +parse +SELECT a FROM t WHERE a = b / c +---- +SELECT a FROM t WHERE a = (b / c) -- normalized! +SELECT (a) FROM t WHERE ((a) = (((b) / (c)))) -- fully parenthetized +SELECT a FROM t WHERE a = (b / c) -- literals removed +SELECT _ FROM _ WHERE _ = (_ / _) -- identifiers removed + +parse +SELECT a FROM t WHERE a = b % c +---- +SELECT a FROM t WHERE a = (b % c) -- normalized! +SELECT (a) FROM t WHERE ((a) = (((b) % (c)))) -- fully parenthetized +SELECT a FROM t WHERE a = (b % c) -- literals removed +SELECT _ FROM _ WHERE _ = (_ % _) -- identifiers removed + +parse +SELECT a FROM t WHERE a = b || c +---- +SELECT a FROM t WHERE a = (b || c) -- normalized! +SELECT (a) FROM t WHERE ((a) = (((b) || (c)))) -- fully parenthetized +SELECT a FROM t WHERE a = (b || c) -- literals removed +SELECT _ FROM _ WHERE _ = (_ || _) -- identifiers removed + +parse +SELECT a FROM t WHERE a = + b +---- +SELECT a FROM t WHERE a = b -- normalized! +SELECT (a) FROM t WHERE ((a) = (b)) -- fully parenthetized +SELECT a FROM t WHERE a = b -- literals removed +SELECT _ FROM _ WHERE _ = _ -- identifiers removed + +parse +SELECT a FROM t WHERE a = - b +---- +SELECT a FROM t WHERE a = (-b) -- normalized! +SELECT (a) FROM t WHERE ((a) = ((-(b)))) -- fully parenthetized +SELECT a FROM t WHERE a = (-b) -- literals removed +SELECT _ FROM _ WHERE _ = (-_) -- identifiers removed + +parse +SELECT a FROM t WHERE a = ~ b +---- +SELECT a FROM t WHERE a = (~b) -- normalized! +SELECT (a) FROM t WHERE ((a) = ((~(b)))) -- fully parenthetized +SELECT a FROM t WHERE a = (~b) -- literals removed +SELECT _ FROM _ WHERE _ = (~_) -- identifiers removed + + +parse +SELECT a FROM t AS bar +---- +SELECT a FROM t AS bar +SELECT (a) FROM t AS bar -- fully parenthetized +SELECT a FROM t AS bar -- literals removed +SELECT _ FROM _ AS _ -- identifiers removed + +parse +SELECT a FROM t AS bar (bar1) +---- +SELECT a FROM t AS bar (bar1) +SELECT (a) FROM t AS bar (bar1) -- fully parenthetized +SELECT a FROM t AS bar (bar1) -- literals removed +SELECT _ FROM _ AS _ (_) -- identifiers removed + +parse +SELECT a FROM t AS bar (bar1, bar2, bar3) +---- +SELECT a FROM t AS bar (bar1, bar2, bar3) +SELECT (a) FROM t AS bar (bar1, bar2, bar3) -- fully parenthetized +SELECT a FROM t AS bar (bar1, bar2, bar3) -- literals removed +SELECT _ FROM _ AS _ (_, _, _) -- identifiers removed + +parse +SELECT a FROM t WITH ORDINALITY +---- +SELECT a FROM t WITH ORDINALITY +SELECT (a) FROM t WITH ORDINALITY -- fully parenthetized +SELECT a FROM t WITH ORDINALITY -- literals removed +SELECT _ FROM _ WITH ORDINALITY -- identifiers removed + +parse +SELECT a FROM t WITH ORDINALITY AS bar +---- +SELECT a FROM t WITH ORDINALITY AS bar +SELECT (a) FROM t WITH ORDINALITY AS bar -- fully parenthetized +SELECT a FROM t WITH ORDINALITY AS bar -- literals removed +SELECT _ FROM _ WITH ORDINALITY AS _ -- identifiers removed + +parse +SELECT a FROM (SELECT 1 FROM t) +---- +SELECT a FROM (SELECT 1 FROM t) +SELECT (a) FROM ((SELECT (1) FROM t)) -- fully parenthetized +SELECT a FROM (SELECT _ FROM t) -- literals removed +SELECT _ FROM (SELECT 1 FROM _) -- identifiers removed + +parse +SELECT a FROM (SELECT 1 FROM t) AS bar +---- +SELECT a FROM (SELECT 1 FROM t) AS bar +SELECT (a) FROM ((SELECT (1) FROM t)) AS bar -- fully parenthetized +SELECT a FROM (SELECT _ FROM t) AS bar -- literals removed +SELECT _ FROM (SELECT 1 FROM _) AS _ -- identifiers removed + +parse +SELECT a FROM (SELECT 1 FROM t) AS bar (bar1) +---- +SELECT a FROM (SELECT 1 FROM t) AS bar (bar1) +SELECT (a) FROM ((SELECT (1) FROM t)) AS bar (bar1) -- fully parenthetized +SELECT a FROM (SELECT _ FROM t) AS bar (bar1) -- literals removed +SELECT _ FROM (SELECT 1 FROM _) AS _ (_) -- identifiers removed + +parse +SELECT a FROM (SELECT 1 FROM t) AS bar (bar1, bar2, bar3) +---- +SELECT a FROM (SELECT 1 FROM t) AS bar (bar1, bar2, bar3) +SELECT (a) FROM ((SELECT (1) FROM t)) AS bar (bar1, bar2, bar3) -- fully parenthetized +SELECT a FROM (SELECT _ FROM t) AS bar (bar1, bar2, bar3) -- literals removed +SELECT _ FROM (SELECT 1 FROM _) AS _ (_, _, _) -- identifiers removed + +parse +SELECT a FROM (SELECT 1 FROM t) WITH ORDINALITY +---- +SELECT a FROM (SELECT 1 FROM t) WITH ORDINALITY +SELECT (a) FROM ((SELECT (1) FROM t)) WITH ORDINALITY -- fully parenthetized +SELECT a FROM (SELECT _ FROM t) WITH ORDINALITY -- literals removed +SELECT _ FROM (SELECT 1 FROM _) WITH ORDINALITY -- identifiers removed + +parse +SELECT a FROM (SELECT 1 FROM t) WITH ORDINALITY AS bar +---- +SELECT a FROM (SELECT 1 FROM t) WITH ORDINALITY AS bar +SELECT (a) FROM ((SELECT (1) FROM t)) WITH ORDINALITY AS bar -- fully parenthetized +SELECT a FROM (SELECT _ FROM t) WITH ORDINALITY AS bar -- literals removed +SELECT _ FROM (SELECT 1 FROM _) WITH ORDINALITY AS _ -- identifiers removed + +parse +SELECT a FROM ROWS FROM (a(x), b(y), c(z)) +---- +SELECT a FROM ROWS FROM (a(x), b(y), c(z)) +SELECT (a) FROM ROWS FROM (((a)((x))), ((b)((y))), ((c)((z)))) -- fully parenthetized +SELECT a FROM ROWS FROM (a(x), b(y), c(z)) -- literals removed +SELECT _ FROM ROWS FROM (a(_), b(_), c(_)) -- identifiers removed + +parse +SELECT a FROM generate_series(1, 32) +---- +SELECT a FROM ROWS FROM (generate_series(1, 32)) -- normalized! +SELECT (a) FROM ROWS FROM (((generate_series)((1), (32)))) -- fully parenthetized +SELECT a FROM ROWS FROM (generate_series(_, _)) -- literals removed +SELECT _ FROM ROWS FROM (generate_series(1, 32)) -- identifiers removed + +parse +SELECT a FROM generate_series(1, 32) AS s (x) +---- +SELECT a FROM ROWS FROM (generate_series(1, 32)) AS s (x) -- normalized! +SELECT (a) FROM ROWS FROM (((generate_series)((1), (32)))) AS s (x) -- fully parenthetized +SELECT a FROM ROWS FROM (generate_series(_, _)) AS s (x) -- literals removed +SELECT _ FROM ROWS FROM (generate_series(1, 32)) AS _ (_) -- identifiers removed + +parse +SELECT a FROM generate_series(1, 32) WITH ORDINALITY AS s (x) +---- +SELECT a FROM ROWS FROM (generate_series(1, 32)) WITH ORDINALITY AS s (x) -- normalized! +SELECT (a) FROM ROWS FROM (((generate_series)((1), (32)))) WITH ORDINALITY AS s (x) -- fully parenthetized +SELECT a FROM ROWS FROM (generate_series(_, _)) WITH ORDINALITY AS s (x) -- literals removed +SELECT _ FROM ROWS FROM (generate_series(1, 32)) WITH ORDINALITY AS _ (_) -- identifiers removed + + +parse +SELECT a FROM t1, t2 +---- +SELECT a FROM t1, t2 +SELECT (a) FROM t1, t2 -- fully parenthetized +SELECT a FROM t1, t2 -- literals removed +SELECT _ FROM _, _ -- identifiers removed + +parse +SELECT a FROM t1, LATERAL (SELECT * FROM t2 WHERE a = b) +---- +SELECT a FROM t1, LATERAL (SELECT * FROM t2 WHERE a = b) +SELECT (a) FROM t1, LATERAL ((SELECT (*) FROM t2 WHERE ((a) = (b)))) -- fully parenthetized +SELECT a FROM t1, LATERAL (SELECT * FROM t2 WHERE a = b) -- literals removed +SELECT _ FROM _, LATERAL (SELECT * FROM _ WHERE _ = _) -- identifiers removed + +parse +SELECT a FROM t1, LATERAL ROWS FROM (generate_series(1, t1.x)) +---- +SELECT a FROM t1, LATERAL ROWS FROM (generate_series(1, t1.x)) +SELECT (a) FROM t1, LATERAL ROWS FROM (((generate_series)((1), (t1.x)))) -- fully parenthetized +SELECT a FROM t1, LATERAL ROWS FROM (generate_series(_, t1.x)) -- literals removed +SELECT _ FROM _, LATERAL ROWS FROM (generate_series(1, _._)) -- identifiers removed + +parse +SELECT a FROM LATERAL generate_series(1, 32) +---- +SELECT a FROM LATERAL ROWS FROM (generate_series(1, 32)) -- normalized! +SELECT (a) FROM LATERAL ROWS FROM (((generate_series)((1), (32)))) -- fully parenthetized +SELECT a FROM LATERAL ROWS FROM (generate_series(_, _)) -- literals removed +SELECT _ FROM LATERAL ROWS FROM (generate_series(1, 32)) -- identifiers removed + + +parse +SELECT a FROM t AS t1 +---- +SELECT a FROM t AS t1 +SELECT (a) FROM t AS t1 -- fully parenthetized +SELECT a FROM t AS t1 -- literals removed +SELECT _ FROM _ AS _ -- identifiers removed + +parse +SELECT a FROM t AS t1 (c1) +---- +SELECT a FROM t AS t1 (c1) +SELECT (a) FROM t AS t1 (c1) -- fully parenthetized +SELECT a FROM t AS t1 (c1) -- literals removed +SELECT _ FROM _ AS _ (_) -- identifiers removed + +parse +SELECT a FROM t AS t1 (c1, c2, c3, c4) +---- +SELECT a FROM t AS t1 (c1, c2, c3, c4) +SELECT (a) FROM t AS t1 (c1, c2, c3, c4) -- fully parenthetized +SELECT a FROM t AS t1 (c1, c2, c3, c4) -- literals removed +SELECT _ FROM _ AS _ (_, _, _, _) -- identifiers removed + +parse +SELECT a FROM s.t +---- +SELECT a FROM s.t +SELECT (a) FROM s.t -- fully parenthetized +SELECT a FROM s.t -- literals removed +SELECT _ FROM _._ -- identifiers removed + +parse +SELECT count(DISTINCT a) FROM t +---- +SELECT count(DISTINCT a) FROM t +SELECT ((count)(DISTINCT (a))) FROM t -- fully parenthetized +SELECT count(DISTINCT a) FROM t -- literals removed +SELECT count(DISTINCT _) FROM _ -- identifiers removed + +parse +SELECT count(ALL a) FROM t +---- +SELECT count(ALL a) FROM t +SELECT ((count)(ALL (a))) FROM t -- fully parenthetized +SELECT count(ALL a) FROM t -- literals removed +SELECT count(ALL _) FROM _ -- identifiers removed + +parse +SELECT a FROM t WHERE a = b +---- +SELECT a FROM t WHERE a = b +SELECT (a) FROM t WHERE ((a) = (b)) -- fully parenthetized +SELECT a FROM t WHERE a = b -- literals removed +SELECT _ FROM _ WHERE _ = _ -- identifiers removed + +parse +SELECT a FROM t WHERE NOT (a = b) +---- +SELECT a FROM t WHERE NOT (a = b) +SELECT (a) FROM t WHERE (NOT ((((a) = (b))))) -- fully parenthetized +SELECT a FROM t WHERE NOT (a = b) -- literals removed +SELECT _ FROM _ WHERE NOT (_ = _) -- identifiers removed + +parse +SELECT a FROM t WHERE EXISTS (SELECT 1 FROM t) +---- +SELECT a FROM t WHERE EXISTS (SELECT 1 FROM t) +SELECT (a) FROM t WHERE (EXISTS (SELECT (1) FROM t)) -- fully parenthetized +SELECT a FROM t WHERE EXISTS (SELECT _ FROM t) -- literals removed +SELECT _ FROM _ WHERE EXISTS (SELECT 1 FROM _) -- identifiers removed + +parse +SELECT a FROM t WHERE NOT true +---- +SELECT a FROM t WHERE NOT true +SELECT (a) FROM t WHERE (NOT (true)) -- fully parenthetized +SELECT a FROM t WHERE NOT _ -- literals removed +SELECT _ FROM _ WHERE NOT true -- identifiers removed + +parse +SELECT a FROM t WHERE NOT false +---- +SELECT a FROM t WHERE NOT false +SELECT (a) FROM t WHERE (NOT (false)) -- fully parenthetized +SELECT a FROM t WHERE NOT _ -- literals removed +SELECT _ FROM _ WHERE NOT false -- identifiers removed + +parse +SELECT a FROM t WHERE a IN (b,) +---- +SELECT a FROM t WHERE a IN (b,) +SELECT (a) FROM t WHERE ((a) IN (((b),))) -- fully parenthetized +SELECT a FROM t WHERE a IN (b,) -- literals removed +SELECT _ FROM _ WHERE _ IN (_,) -- identifiers removed + +parse +SELECT a FROM t WHERE a IN (b, c) +---- +SELECT a FROM t WHERE a IN (b, c) +SELECT (a) FROM t WHERE ((a) IN (((b), (c)))) -- fully parenthetized +SELECT a FROM t WHERE a IN (b, c) -- literals removed +SELECT _ FROM _ WHERE _ IN (_, _) -- identifiers removed + +parse +SELECT a FROM t WHERE a IN (SELECT a FROM t) +---- +SELECT a FROM t WHERE a IN (SELECT a FROM t) +SELECT (a) FROM t WHERE ((a) IN ((SELECT (a) FROM t))) -- fully parenthetized +SELECT a FROM t WHERE a IN (SELECT a FROM t) -- literals removed +SELECT _ FROM _ WHERE _ IN (SELECT _ FROM _) -- identifiers removed + +parse +SELECT a FROM t WHERE a NOT IN (b, c) +---- +SELECT a FROM t WHERE a NOT IN (b, c) +SELECT (a) FROM t WHERE ((a) NOT IN (((b), (c)))) -- fully parenthetized +SELECT a FROM t WHERE a NOT IN (b, c) -- literals removed +SELECT _ FROM _ WHERE _ NOT IN (_, _) -- identifiers removed + +parse +SELECT a FROM t WHERE a = ANY (ARRAY[b, c]) +---- +SELECT a FROM t WHERE a = ANY (ARRAY[b, c]) +SELECT (a) FROM t WHERE ((a) = ANY (((ARRAY[(b), (c)])))) -- fully parenthetized +SELECT a FROM t WHERE a = ANY (ARRAY[b, c]) -- literals removed +SELECT _ FROM _ WHERE _ = ANY (ARRAY[_, _]) -- identifiers removed + +parse +SELECT a FROM t WHERE a = ANY ARRAY[b, c] +---- +SELECT a FROM t WHERE a = ANY ARRAY[b, c] +SELECT (a) FROM t WHERE ((a) = ANY (ARRAY[(b), (c)])) -- fully parenthetized +SELECT a FROM t WHERE a = ANY ARRAY[b, c] -- literals removed +SELECT _ FROM _ WHERE _ = ANY ARRAY[_, _] -- identifiers removed + +parse +SELECT a FROM t WHERE a != SOME (ARRAY[b, c]) +---- +SELECT a FROM t WHERE a != SOME (ARRAY[b, c]) +SELECT (a) FROM t WHERE ((a) != SOME (((ARRAY[(b), (c)])))) -- fully parenthetized +SELECT a FROM t WHERE a != SOME (ARRAY[b, c]) -- literals removed +SELECT _ FROM _ WHERE _ != SOME (ARRAY[_, _]) -- identifiers removed + +parse +SELECT a FROM t WHERE a != SOME ARRAY[b, c] +---- +SELECT a FROM t WHERE a != SOME ARRAY[b, c] +SELECT (a) FROM t WHERE ((a) != SOME (ARRAY[(b), (c)])) -- fully parenthetized +SELECT a FROM t WHERE a != SOME ARRAY[b, c] -- literals removed +SELECT _ FROM _ WHERE _ != SOME ARRAY[_, _] -- identifiers removed + +parse +SELECT a FROM t WHERE a = ANY (SELECT 1) +---- +SELECT a FROM t WHERE a = ANY (SELECT 1) +SELECT (a) FROM t WHERE ((a) = ANY ((SELECT (1)))) -- fully parenthetized +SELECT a FROM t WHERE a = ANY (SELECT _) -- literals removed +SELECT _ FROM _ WHERE _ = ANY (SELECT 1) -- identifiers removed + +parse +SELECT a FROM t WHERE a LIKE ALL (ARRAY[b, c]) +---- +SELECT a FROM t WHERE a LIKE ALL (ARRAY[b, c]) +SELECT (a) FROM t WHERE ((a) LIKE ALL (((ARRAY[(b), (c)])))) -- fully parenthetized +SELECT a FROM t WHERE a LIKE ALL (ARRAY[b, c]) -- literals removed +SELECT _ FROM _ WHERE _ LIKE ALL (ARRAY[_, _]) -- identifiers removed + +parse +SELECT a FROM t WHERE a LIKE ALL ARRAY[b, c] +---- +SELECT a FROM t WHERE a LIKE ALL ARRAY[b, c] +SELECT (a) FROM t WHERE ((a) LIKE ALL (ARRAY[(b), (c)])) -- fully parenthetized +SELECT a FROM t WHERE a LIKE ALL ARRAY[b, c] -- literals removed +SELECT _ FROM _ WHERE _ LIKE ALL ARRAY[_, _] -- identifiers removed + +parse +SELECT a FROM t WHERE a LIKE b +---- +SELECT a FROM t WHERE a LIKE b +SELECT (a) FROM t WHERE ((a) LIKE (b)) -- fully parenthetized +SELECT a FROM t WHERE a LIKE b -- literals removed +SELECT _ FROM _ WHERE _ LIKE _ -- identifiers removed + +parse +SELECT a FROM t WHERE a NOT LIKE b +---- +SELECT a FROM t WHERE a NOT LIKE b +SELECT (a) FROM t WHERE ((a) NOT LIKE (b)) -- fully parenthetized +SELECT a FROM t WHERE a NOT LIKE b -- literals removed +SELECT _ FROM _ WHERE _ NOT LIKE _ -- identifiers removed + +parse +SELECT a FROM t WHERE a ILIKE b +---- +SELECT a FROM t WHERE a ILIKE b +SELECT (a) FROM t WHERE ((a) ILIKE (b)) -- fully parenthetized +SELECT a FROM t WHERE a ILIKE b -- literals removed +SELECT _ FROM _ WHERE _ ILIKE _ -- identifiers removed + +parse +SELECT a FROM t WHERE a NOT ILIKE b +---- +SELECT a FROM t WHERE a NOT ILIKE b +SELECT (a) FROM t WHERE ((a) NOT ILIKE (b)) -- fully parenthetized +SELECT a FROM t WHERE a NOT ILIKE b -- literals removed +SELECT _ FROM _ WHERE _ NOT ILIKE _ -- identifiers removed + +parse +SELECT a FROM t WHERE a SIMILAR TO b +---- +SELECT a FROM t WHERE a SIMILAR TO b +SELECT (a) FROM t WHERE ((a) SIMILAR TO (b)) -- fully parenthetized +SELECT a FROM t WHERE a SIMILAR TO b -- literals removed +SELECT _ FROM _ WHERE _ SIMILAR TO _ -- identifiers removed + +parse +SELECT a FROM t WHERE a NOT SIMILAR TO b +---- +SELECT a FROM t WHERE a NOT SIMILAR TO b +SELECT (a) FROM t WHERE ((a) NOT SIMILAR TO (b)) -- fully parenthetized +SELECT a FROM t WHERE a NOT SIMILAR TO b -- literals removed +SELECT _ FROM _ WHERE _ NOT SIMILAR TO _ -- identifiers removed + +parse +SELECT a FROM t WHERE a ~ b +---- +SELECT a FROM t WHERE a ~ b +SELECT (a) FROM t WHERE ((a) ~ (b)) -- fully parenthetized +SELECT a FROM t WHERE a ~ b -- literals removed +SELECT _ FROM _ WHERE _ ~ _ -- identifiers removed + +parse +SELECT a FROM t WHERE a !~ b +---- +SELECT a FROM t WHERE a !~ b +SELECT (a) FROM t WHERE ((a) !~ (b)) -- fully parenthetized +SELECT a FROM t WHERE a !~ b -- literals removed +SELECT _ FROM _ WHERE _ !~ _ -- identifiers removed + +parse +SELECT a FROM t WHERE a ~* c +---- +SELECT a FROM t WHERE a ~* c +SELECT (a) FROM t WHERE ((a) ~* (c)) -- fully parenthetized +SELECT a FROM t WHERE a ~* c -- literals removed +SELECT _ FROM _ WHERE _ ~* _ -- identifiers removed + +parse +SELECT a FROM t WHERE a !~* c +---- +SELECT a FROM t WHERE a !~* c +SELECT (a) FROM t WHERE ((a) !~* (c)) -- fully parenthetized +SELECT a FROM t WHERE a !~* c -- literals removed +SELECT _ FROM _ WHERE _ !~* _ -- identifiers removed + +parse +SELECT a FROM t WHERE a BETWEEN b AND c +---- +SELECT a FROM t WHERE a BETWEEN b AND c +SELECT (a) FROM t WHERE ((a) BETWEEN (b) AND (c)) -- fully parenthetized +SELECT a FROM t WHERE a BETWEEN b AND c -- literals removed +SELECT _ FROM _ WHERE _ BETWEEN _ AND _ -- identifiers removed + +parse +SELECT a FROM t WHERE a BETWEEN SYMMETRIC b AND c +---- +SELECT a FROM t WHERE a BETWEEN SYMMETRIC b AND c +SELECT (a) FROM t WHERE ((a) BETWEEN SYMMETRIC (b) AND (c)) -- fully parenthetized +SELECT a FROM t WHERE a BETWEEN SYMMETRIC b AND c -- literals removed +SELECT _ FROM _ WHERE _ BETWEEN SYMMETRIC _ AND _ -- identifiers removed + +parse +SELECT a FROM t WHERE a NOT BETWEEN b AND c +---- +SELECT a FROM t WHERE a NOT BETWEEN b AND c +SELECT (a) FROM t WHERE ((a) NOT BETWEEN (b) AND (c)) -- fully parenthetized +SELECT a FROM t WHERE a NOT BETWEEN b AND c -- literals removed +SELECT _ FROM _ WHERE _ NOT BETWEEN _ AND _ -- identifiers removed + +parse +SELECT a FROM t WHERE a NOT BETWEEN SYMMETRIC b AND c +---- +SELECT a FROM t WHERE a NOT BETWEEN SYMMETRIC b AND c +SELECT (a) FROM t WHERE ((a) NOT BETWEEN SYMMETRIC (b) AND (c)) -- fully parenthetized +SELECT a FROM t WHERE a NOT BETWEEN SYMMETRIC b AND c -- literals removed +SELECT _ FROM _ WHERE _ NOT BETWEEN SYMMETRIC _ AND _ -- identifiers removed + +parse +SELECT a FROM t WHERE a BETWEEN ASYMMETRIC b AND c +---- +SELECT a FROM t WHERE a BETWEEN b AND c -- normalized! +SELECT (a) FROM t WHERE ((a) BETWEEN (b) AND (c)) -- fully parenthetized +SELECT a FROM t WHERE a BETWEEN b AND c -- literals removed +SELECT _ FROM _ WHERE _ BETWEEN _ AND _ -- identifiers removed + + +parse +SELECT a FROM t WHERE a IS NULL +---- +SELECT a FROM t WHERE a IS NULL +SELECT (a) FROM t WHERE ((a) IS NULL) -- fully parenthetized +SELECT a FROM t WHERE a IS NULL -- literals removed +SELECT _ FROM _ WHERE _ IS NULL -- identifiers removed + +parse +SELECT a FROM t WHERE a IS NOT NULL +---- +SELECT a FROM t WHERE a IS NOT NULL +SELECT (a) FROM t WHERE ((a) IS NOT NULL) -- fully parenthetized +SELECT a FROM t WHERE a IS NOT NULL -- literals removed +SELECT _ FROM _ WHERE _ IS NOT NULL -- identifiers removed + +parse +SELECT a FROM t WHERE (a, b) IS NULL +---- +SELECT a FROM t WHERE (a, b) IS NULL +SELECT (a) FROM t WHERE ((((a), (b))) IS NULL) -- fully parenthetized +SELECT a FROM t WHERE (a, b) IS NULL -- literals removed +SELECT _ FROM _ WHERE (_, _) IS NULL -- identifiers removed + +parse +SELECT a FROM t WHERE (a, b) IS NOT NULL +---- +SELECT a FROM t WHERE (a, b) IS NOT NULL +SELECT (a) FROM t WHERE ((((a), (b))) IS NOT NULL) -- fully parenthetized +SELECT a FROM t WHERE (a, b) IS NOT NULL -- literals removed +SELECT _ FROM _ WHERE (_, _) IS NOT NULL -- identifiers removed + +parse +SELECT a FROM t WHERE a ISNULL +---- +SELECT a FROM t WHERE a IS NULL -- normalized! +SELECT (a) FROM t WHERE ((a) IS NULL) -- fully parenthetized +SELECT a FROM t WHERE a IS NULL -- literals removed +SELECT _ FROM _ WHERE _ IS NULL -- identifiers removed + +parse +SELECT a FROM t WHERE a NOTNULL +---- +SELECT a FROM t WHERE a IS NOT NULL -- normalized! +SELECT (a) FROM t WHERE ((a) IS NOT NULL) -- fully parenthetized +SELECT a FROM t WHERE a IS NOT NULL -- literals removed +SELECT _ FROM _ WHERE _ IS NOT NULL -- identifiers removed + +parse +SELECT a FROM t WHERE a IS UNKNOWN +---- +SELECT a FROM t WHERE a IS NOT DISTINCT FROM NULL -- normalized! +SELECT (a) FROM t WHERE ((a) IS NOT DISTINCT FROM (NULL)) -- fully parenthetized +SELECT a FROM t WHERE a IS NOT DISTINCT FROM _ -- literals removed +SELECT _ FROM _ WHERE _ IS NOT DISTINCT FROM NULL -- identifiers removed + +parse +SELECT a FROM t WHERE a IS NOT UNKNOWN +---- +SELECT a FROM t WHERE a IS DISTINCT FROM NULL -- normalized! +SELECT (a) FROM t WHERE ((a) IS DISTINCT FROM (NULL)) -- fully parenthetized +SELECT a FROM t WHERE a IS DISTINCT FROM _ -- literals removed +SELECT _ FROM _ WHERE _ IS DISTINCT FROM NULL -- identifiers removed + +parse +SELECT a FROM t WHERE a IS true +---- +SELECT a FROM t WHERE a IS true +SELECT (a) FROM t WHERE ((a) IS (true)) -- fully parenthetized +SELECT a FROM t WHERE a IS _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +SELECT _ FROM _ WHERE _ IS true -- identifiers removed + +parse +SELECT a FROM t WHERE a IS NOT true +---- +SELECT a FROM t WHERE a IS NOT true +SELECT (a) FROM t WHERE ((a) IS NOT (true)) -- fully parenthetized +SELECT a FROM t WHERE a IS NOT _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +SELECT _ FROM _ WHERE _ IS NOT true -- identifiers removed + +parse +SELECT a FROM t WHERE a IS false +---- +SELECT a FROM t WHERE a IS false +SELECT (a) FROM t WHERE ((a) IS (false)) -- fully parenthetized +SELECT a FROM t WHERE a IS _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +SELECT _ FROM _ WHERE _ IS false -- identifiers removed + +parse +SELECT a FROM t WHERE a IS NOT false +---- +SELECT a FROM t WHERE a IS NOT false +SELECT (a) FROM t WHERE ((a) IS NOT (false)) -- fully parenthetized +SELECT a FROM t WHERE a IS NOT _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +SELECT _ FROM _ WHERE _ IS NOT false -- identifiers removed + +parse +SELECT a FROM t WHERE a IS OF (INT8) +---- +SELECT a FROM t WHERE a IS OF (INT8) +SELECT (a) FROM t WHERE ((a) IS OF (INT8)) -- fully parenthetized +SELECT a FROM t WHERE a IS OF (INT8) -- literals removed +SELECT _ FROM _ WHERE _ IS OF (INT8) -- identifiers removed + +parse +SELECT a FROM t WHERE a IS NOT OF (FLOAT8, STRING) +---- +SELECT a FROM t WHERE a IS NOT OF (FLOAT8, STRING) +SELECT (a) FROM t WHERE ((a) IS NOT OF (FLOAT8, STRING)) -- fully parenthetized +SELECT a FROM t WHERE a IS NOT OF (FLOAT8, STRING) -- literals removed +SELECT _ FROM _ WHERE _ IS NOT OF (FLOAT8, STRING) -- identifiers removed + +parse +SELECT a FROM t WHERE a IS DISTINCT FROM b +---- +SELECT a FROM t WHERE a IS DISTINCT FROM b +SELECT (a) FROM t WHERE ((a) IS DISTINCT FROM (b)) -- fully parenthetized +SELECT a FROM t WHERE a IS DISTINCT FROM b -- literals removed +SELECT _ FROM _ WHERE _ IS DISTINCT FROM _ -- identifiers removed + +parse +SELECT a FROM t WHERE a IS NOT DISTINCT FROM b +---- +SELECT a FROM t WHERE a IS NOT DISTINCT FROM b +SELECT (a) FROM t WHERE ((a) IS NOT DISTINCT FROM (b)) -- fully parenthetized +SELECT a FROM t WHERE a IS NOT DISTINCT FROM b -- literals removed +SELECT _ FROM _ WHERE _ IS NOT DISTINCT FROM _ -- identifiers removed + +parse +SELECT a FROM t WHERE (a, b) IS NOT DISTINCT FROM NULL +---- +SELECT a FROM t WHERE (a, b) IS NOT DISTINCT FROM NULL +SELECT (a) FROM t WHERE ((((a), (b))) IS NOT DISTINCT FROM (NULL)) -- fully parenthetized +SELECT a FROM t WHERE (a, b) IS NOT DISTINCT FROM _ -- literals removed +SELECT _ FROM _ WHERE (_, _) IS NOT DISTINCT FROM NULL -- identifiers removed + +parse +SELECT a FROM t WHERE (a, b) IS DISTINCT FROM NULL +---- +SELECT a FROM t WHERE (a, b) IS DISTINCT FROM NULL +SELECT (a) FROM t WHERE ((((a), (b))) IS DISTINCT FROM (NULL)) -- fully parenthetized +SELECT a FROM t WHERE (a, b) IS DISTINCT FROM _ -- literals removed +SELECT _ FROM _ WHERE (_, _) IS DISTINCT FROM NULL -- identifiers removed + +parse +SELECT a FROM t WHERE a < b +---- +SELECT a FROM t WHERE a < b +SELECT (a) FROM t WHERE ((a) < (b)) -- fully parenthetized +SELECT a FROM t WHERE a < b -- literals removed +SELECT _ FROM _ WHERE _ < _ -- identifiers removed + +parse +SELECT a FROM t WHERE a <= b +---- +SELECT a FROM t WHERE a <= b +SELECT (a) FROM t WHERE ((a) <= (b)) -- fully parenthetized +SELECT a FROM t WHERE a <= b -- literals removed +SELECT _ FROM _ WHERE _ <= _ -- identifiers removed + +parse +SELECT a FROM t WHERE a >= b +---- +SELECT a FROM t WHERE a >= b +SELECT (a) FROM t WHERE ((a) >= (b)) -- fully parenthetized +SELECT a FROM t WHERE a >= b -- literals removed +SELECT _ FROM _ WHERE _ >= _ -- identifiers removed + +parse +SELECT a FROM t WHERE a != b +---- +SELECT a FROM t WHERE a != b +SELECT (a) FROM t WHERE ((a) != (b)) -- fully parenthetized +SELECT a FROM t WHERE a != b -- literals removed +SELECT _ FROM _ WHERE _ != _ -- identifiers removed + +parse +SELECT a FROM t WHERE a = (SELECT a FROM t) +---- +SELECT a FROM t WHERE a = (SELECT a FROM t) +SELECT (a) FROM t WHERE ((a) = ((SELECT (a) FROM t))) -- fully parenthetized +SELECT a FROM t WHERE a = (SELECT a FROM t) -- literals removed +SELECT _ FROM _ WHERE _ = (SELECT _ FROM _) -- identifiers removed + +parse +SELECT a FROM t WHERE a = (b) +---- +SELECT a FROM t WHERE a = (b) +SELECT (a) FROM t WHERE ((a) = (((b)))) -- fully parenthetized +SELECT a FROM t WHERE a = (b) -- literals removed +SELECT _ FROM _ WHERE _ = (_) -- identifiers removed + +parse +SELECT a FROM t WHERE CASE WHEN a = b THEN c END +---- +SELECT a FROM t WHERE CASE WHEN a = b THEN c END +SELECT (a) FROM t WHERE (CASE WHEN ((a) = (b)) THEN (c) END) -- fully parenthetized +SELECT a FROM t WHERE CASE WHEN a = b THEN c END -- literals removed +SELECT _ FROM _ WHERE CASE WHEN _ = _ THEN _ END -- identifiers removed + +parse +SELECT a FROM t WHERE CASE WHEN a = b THEN c ELSE d END +---- +SELECT a FROM t WHERE CASE WHEN a = b THEN c ELSE d END +SELECT (a) FROM t WHERE (CASE WHEN ((a) = (b)) THEN (c) ELSE (d) END) -- fully parenthetized +SELECT a FROM t WHERE CASE WHEN a = b THEN c ELSE d END -- literals removed +SELECT _ FROM _ WHERE CASE WHEN _ = _ THEN _ ELSE _ END -- identifiers removed + +parse +SELECT a FROM t WHERE CASE WHEN a = b THEN c WHEN b = d THEN d ELSE d END +---- +SELECT a FROM t WHERE CASE WHEN a = b THEN c WHEN b = d THEN d ELSE d END +SELECT (a) FROM t WHERE (CASE WHEN ((a) = (b)) THEN (c) WHEN ((b) = (d)) THEN (d) ELSE (d) END) -- fully parenthetized +SELECT a FROM t WHERE CASE WHEN a = b THEN c WHEN b = d THEN d ELSE d END -- literals removed +SELECT _ FROM _ WHERE CASE WHEN _ = _ THEN _ WHEN _ = _ THEN _ ELSE _ END -- identifiers removed + +parse +SELECT a FROM t WHERE CASE aa WHEN a = b THEN c END +---- +SELECT a FROM t WHERE CASE aa WHEN a = b THEN c END +SELECT (a) FROM t WHERE (CASE (aa) WHEN ((a) = (b)) THEN (c) END) -- fully parenthetized +SELECT a FROM t WHERE CASE aa WHEN a = b THEN c END -- literals removed +SELECT _ FROM _ WHERE CASE _ WHEN _ = _ THEN _ END -- identifiers removed + +parse +SELECT a FROM t WHERE a = b() +---- +SELECT a FROM t WHERE a = b() +SELECT (a) FROM t WHERE ((a) = ((b)())) -- fully parenthetized +SELECT a FROM t WHERE a = b() -- literals removed +SELECT _ FROM _ WHERE _ = b() -- identifiers removed + +parse +SELECT a FROM t WHERE a = b(c) +---- +SELECT a FROM t WHERE a = b(c) +SELECT (a) FROM t WHERE ((a) = ((b)((c)))) -- fully parenthetized +SELECT a FROM t WHERE a = b(c) -- literals removed +SELECT _ FROM _ WHERE _ = b(_) -- identifiers removed + +parse +SELECT a FROM t WHERE a = b(c, d) +---- +SELECT a FROM t WHERE a = b(c, d) +SELECT (a) FROM t WHERE ((a) = ((b)((c), (d)))) -- fully parenthetized +SELECT a FROM t WHERE a = b(c, d) -- literals removed +SELECT _ FROM _ WHERE _ = b(_, _) -- identifiers removed + +parse +SELECT a FROM t WHERE a = count(*) +---- +SELECT a FROM t WHERE a = count(*) +SELECT (a) FROM t WHERE ((a) = ((count)((*)))) -- fully parenthetized +SELECT a FROM t WHERE a = count(*) -- literals removed +SELECT _ FROM _ WHERE _ = count(*) -- identifiers removed + +parse +SELECT a FROM t WHERE a = IF(b, c, d) +---- +SELECT a FROM t WHERE a = IF(b, c, d) +SELECT (a) FROM t WHERE ((a) = (IF((b), (c), (d)))) -- fully parenthetized +SELECT a FROM t WHERE a = IF(b, c, d) -- literals removed +SELECT _ FROM _ WHERE _ = IF(_, _, _) -- identifiers removed + +parse +SELECT a FROM t WHERE a = IFERROR(b, c, d) +---- +SELECT a FROM t WHERE a = IFERROR(b, c, d) +SELECT (a) FROM t WHERE ((a) = (IFERROR((b), (c), (d)))) -- fully parenthetized +SELECT a FROM t WHERE a = IFERROR(b, c, d) -- literals removed +SELECT _ FROM _ WHERE _ = IFERROR(_, _, _) -- identifiers removed + +parse +SELECT a FROM t WHERE a = IFERROR(b, c) +---- +SELECT a FROM t WHERE a = IFERROR(b, c) +SELECT (a) FROM t WHERE ((a) = (IFERROR((b), (c)))) -- fully parenthetized +SELECT a FROM t WHERE a = IFERROR(b, c) -- literals removed +SELECT _ FROM _ WHERE _ = IFERROR(_, _) -- identifiers removed + +parse +SELECT a FROM t WHERE a = ISERROR(b) +---- +SELECT a FROM t WHERE a = ISERROR(b) +SELECT (a) FROM t WHERE ((a) = (ISERROR((b)))) -- fully parenthetized +SELECT a FROM t WHERE a = ISERROR(b) -- literals removed +SELECT _ FROM _ WHERE _ = ISERROR(_) -- identifiers removed + +parse +SELECT a FROM t WHERE a = ISERROR(b, c) +---- +SELECT a FROM t WHERE a = ISERROR(b, c) +SELECT (a) FROM t WHERE ((a) = (ISERROR((b), (c)))) -- fully parenthetized +SELECT a FROM t WHERE a = ISERROR(b, c) -- literals removed +SELECT _ FROM _ WHERE _ = ISERROR(_, _) -- identifiers removed + +parse +SELECT a FROM t WHERE a = IFNULL(b, c) +---- +SELECT a FROM t WHERE a = IFNULL(b, c) +SELECT (a) FROM t WHERE ((a) = (IFNULL((b), (c)))) -- fully parenthetized +SELECT a FROM t WHERE a = IFNULL(b, c) -- literals removed +SELECT _ FROM _ WHERE _ = IFNULL(_, _) -- identifiers removed + +parse +SELECT a FROM t WHERE a = NULLIF(b, c) +---- +SELECT a FROM t WHERE a = NULLIF(b, c) +SELECT (a) FROM t WHERE ((a) = (NULLIF((b), (c)))) -- fully parenthetized +SELECT a FROM t WHERE a = NULLIF(b, c) -- literals removed +SELECT _ FROM _ WHERE _ = NULLIF(_, _) -- identifiers removed + +parse +SELECT a FROM t WHERE a = COALESCE(a, b, c, d, e) +---- +SELECT a FROM t WHERE a = COALESCE(a, b, c, d, e) +SELECT (a) FROM t WHERE ((a) = (COALESCE((a), (b), (c), (d), (e)))) -- fully parenthetized +SELECT a FROM t WHERE a = COALESCE(a, b, c, d, e) -- literals removed +SELECT _ FROM _ WHERE _ = COALESCE(_, _, _, _, _) -- identifiers removed + +parse +SELECT (a.b) FROM t WHERE (b.c) = 2 +---- +SELECT (a.b) FROM t WHERE (b.c) = 2 +SELECT (((a.b))) FROM t WHERE ((((b.c))) = (2)) -- fully parenthetized +SELECT (a.b) FROM t WHERE (b.c) = _ -- literals removed +SELECT (_._) FROM _ WHERE (_._) = 2 -- identifiers removed + +parse +SELECT a FROM t ORDER BY a +---- +SELECT a FROM t ORDER BY a +SELECT (a) FROM t ORDER BY (a) -- fully parenthetized +SELECT a FROM t ORDER BY a -- literals removed +SELECT _ FROM _ ORDER BY _ -- identifiers removed + +parse +SELECT a FROM t ORDER BY a ASC +---- +SELECT a FROM t ORDER BY a ASC +SELECT (a) FROM t ORDER BY (a) ASC -- fully parenthetized +SELECT a FROM t ORDER BY a ASC -- literals removed +SELECT _ FROM _ ORDER BY _ ASC -- identifiers removed + +parse +SELECT a FROM t ORDER BY a DESC +---- +SELECT a FROM t ORDER BY a DESC +SELECT (a) FROM t ORDER BY (a) DESC -- fully parenthetized +SELECT a FROM t ORDER BY a DESC -- literals removed +SELECT _ FROM _ ORDER BY _ DESC -- identifiers removed + +parse +SELECT a FROM t ORDER BY PRIMARY KEY t +---- +SELECT a FROM t ORDER BY PRIMARY KEY t +SELECT (a) FROM t ORDER BY PRIMARY KEY t -- fully parenthetized +SELECT a FROM t ORDER BY PRIMARY KEY t -- literals removed +SELECT _ FROM _ ORDER BY PRIMARY KEY _ -- identifiers removed + +parse +SELECT a FROM t ORDER BY PRIMARY KEY t ASC +---- +SELECT a FROM t ORDER BY PRIMARY KEY t ASC +SELECT (a) FROM t ORDER BY PRIMARY KEY t ASC -- fully parenthetized +SELECT a FROM t ORDER BY PRIMARY KEY t ASC -- literals removed +SELECT _ FROM _ ORDER BY PRIMARY KEY _ ASC -- identifiers removed + +parse +SELECT a FROM t ORDER BY PRIMARY KEY t DESC +---- +SELECT a FROM t ORDER BY PRIMARY KEY t DESC +SELECT (a) FROM t ORDER BY PRIMARY KEY t DESC -- fully parenthetized +SELECT a FROM t ORDER BY PRIMARY KEY t DESC -- literals removed +SELECT _ FROM _ ORDER BY PRIMARY KEY _ DESC -- identifiers removed + +parse +SELECT a FROM t ORDER BY INDEX t@foo +---- +SELECT a FROM t ORDER BY INDEX t@foo +SELECT (a) FROM t ORDER BY INDEX t@foo -- fully parenthetized +SELECT a FROM t ORDER BY INDEX t@foo -- literals removed +SELECT _ FROM _ ORDER BY INDEX _@_ -- identifiers removed + +parse +SELECT a FROM t ORDER BY INDEX t@foo ASC +---- +SELECT a FROM t ORDER BY INDEX t@foo ASC +SELECT (a) FROM t ORDER BY INDEX t@foo ASC -- fully parenthetized +SELECT a FROM t ORDER BY INDEX t@foo ASC -- literals removed +SELECT _ FROM _ ORDER BY INDEX _@_ ASC -- identifiers removed + +parse +SELECT a FROM t ORDER BY INDEX t@foo DESC +---- +SELECT a FROM t ORDER BY INDEX t@foo DESC +SELECT (a) FROM t ORDER BY INDEX t@foo DESC -- fully parenthetized +SELECT a FROM t ORDER BY INDEX t@foo DESC -- literals removed +SELECT _ FROM _ ORDER BY INDEX _@_ DESC -- identifiers removed + +parse +SELECT a FROM t ORDER BY INDEX t@primary +---- +SELECT a FROM t ORDER BY INDEX t@primary +SELECT (a) FROM t ORDER BY INDEX t@primary -- fully parenthetized +SELECT a FROM t ORDER BY INDEX t@primary -- literals removed +SELECT _ FROM _ ORDER BY INDEX _@_ -- identifiers removed + +parse +SELECT a FROM t ORDER BY INDEX t@like +---- +SELECT a FROM t ORDER BY INDEX t@like +SELECT (a) FROM t ORDER BY INDEX t@like -- fully parenthetized +SELECT a FROM t ORDER BY INDEX t@like -- literals removed +SELECT _ FROM _ ORDER BY INDEX _@_ -- identifiers removed + +parse +SELECT a FROM t ORDER BY a NULLS FIRST +---- +SELECT a FROM t ORDER BY a NULLS FIRST +SELECT (a) FROM t ORDER BY (a) NULLS FIRST -- fully parenthetized +SELECT a FROM t ORDER BY a NULLS FIRST -- literals removed +SELECT _ FROM _ ORDER BY _ NULLS FIRST -- identifiers removed + +parse +SELECT a FROM t ORDER BY a ASC NULLS FIRST +---- +SELECT a FROM t ORDER BY a ASC NULLS FIRST +SELECT (a) FROM t ORDER BY (a) ASC NULLS FIRST -- fully parenthetized +SELECT a FROM t ORDER BY a ASC NULLS FIRST -- literals removed +SELECT _ FROM _ ORDER BY _ ASC NULLS FIRST -- identifiers removed + +parse +SELECT a FROM t ORDER BY a DESC NULLS LAST +---- +SELECT a FROM t ORDER BY a DESC NULLS LAST +SELECT (a) FROM t ORDER BY (a) DESC NULLS LAST -- fully parenthetized +SELECT a FROM t ORDER BY a DESC NULLS LAST -- literals removed +SELECT _ FROM _ ORDER BY _ DESC NULLS LAST -- identifiers removed + +parse +SELECT 1 FROM t GROUP BY a +---- +SELECT 1 FROM t GROUP BY a +SELECT (1) FROM t GROUP BY (a) -- fully parenthetized +SELECT _ FROM t GROUP BY a -- literals removed +SELECT 1 FROM _ GROUP BY _ -- identifiers removed + +parse +SELECT 1 FROM t GROUP BY a, b +---- +SELECT 1 FROM t GROUP BY a, b +SELECT (1) FROM t GROUP BY (a), (b) -- fully parenthetized +SELECT _ FROM t GROUP BY a, b -- literals removed +SELECT 1 FROM _ GROUP BY _, _ -- identifiers removed + +parse +SELECT 1 FROM t GROUP BY () +---- +SELECT 1 FROM t GROUP BY () +SELECT (1) FROM t GROUP BY (()) -- fully parenthetized +SELECT _ FROM t GROUP BY () -- literals removed +SELECT 1 FROM _ GROUP BY () -- identifiers removed + +parse +SELECT sum(x ORDER BY y) FROM t +---- +SELECT sum(x ORDER BY y) FROM t +SELECT ((sum)((x) ORDER BY (y))) FROM t -- fully parenthetized +SELECT sum(x ORDER BY y) FROM t -- literals removed +SELECT sum(_ ORDER BY _) FROM _ -- identifiers removed + +parse +SELECT sum(x ORDER BY y, z) FROM t +---- +SELECT sum(x ORDER BY y, z) FROM t +SELECT ((sum)((x) ORDER BY (y), (z))) FROM t -- fully parenthetized +SELECT sum(x ORDER BY y, z) FROM t -- literals removed +SELECT sum(_ ORDER BY _, _) FROM _ -- identifiers removed + +parse +SELECT a FROM t HAVING a = b +---- +SELECT a FROM t HAVING a = b +SELECT (a) FROM t HAVING ((a) = (b)) -- fully parenthetized +SELECT a FROM t HAVING a = b -- literals removed +SELECT _ FROM _ HAVING _ = _ -- identifiers removed + +parse +SELECT a FROM t WINDOW w AS () +---- +SELECT a FROM t WINDOW w AS () +SELECT (a) FROM t WINDOW w AS () -- fully parenthetized +SELECT a FROM t WINDOW w AS () -- literals removed +SELECT _ FROM _ WINDOW _ AS () -- identifiers removed + +parse +SELECT a FROM t WINDOW w AS (w2) +---- +SELECT a FROM t WINDOW w AS (w2) +SELECT (a) FROM t WINDOW w AS (w2) -- fully parenthetized +SELECT a FROM t WINDOW w AS (w2) -- literals removed +SELECT _ FROM _ WINDOW _ AS (_) -- identifiers removed + +parse +SELECT a FROM t WINDOW w AS (PARTITION BY b) +---- +SELECT a FROM t WINDOW w AS (PARTITION BY b) +SELECT (a) FROM t WINDOW w AS (PARTITION BY (b)) -- fully parenthetized +SELECT a FROM t WINDOW w AS (PARTITION BY b) -- literals removed +SELECT _ FROM _ WINDOW _ AS (PARTITION BY _) -- identifiers removed + +parse +SELECT a FROM t WINDOW w AS (PARTITION BY b, 1 + 2) +---- +SELECT a FROM t WINDOW w AS (PARTITION BY b, 1 + 2) +SELECT (a) FROM t WINDOW w AS (PARTITION BY (b), ((1) + (2))) -- fully parenthetized +SELECT a FROM t WINDOW w AS (PARTITION BY b, _ + _) -- literals removed +SELECT _ FROM _ WINDOW _ AS (PARTITION BY _, 1 + 2) -- identifiers removed + +parse +SELECT a FROM t WINDOW w AS (ORDER BY c) +---- +SELECT a FROM t WINDOW w AS (ORDER BY c) +SELECT (a) FROM t WINDOW w AS (ORDER BY (c)) -- fully parenthetized +SELECT a FROM t WINDOW w AS (ORDER BY c) -- literals removed +SELECT _ FROM _ WINDOW _ AS (ORDER BY _) -- identifiers removed + +parse +SELECT a FROM t WINDOW w AS (ORDER BY c, 1 + 2) +---- +SELECT a FROM t WINDOW w AS (ORDER BY c, 1 + 2) +SELECT (a) FROM t WINDOW w AS (ORDER BY (c), ((1) + (2))) -- fully parenthetized +SELECT a FROM t WINDOW w AS (ORDER BY c, _ + _) -- literals removed +SELECT _ FROM _ WINDOW _ AS (ORDER BY _, 1 + 2) -- identifiers removed + +parse +SELECT a FROM t WINDOW w AS (PARTITION BY b ORDER BY c) +---- +SELECT a FROM t WINDOW w AS (PARTITION BY b ORDER BY c) +SELECT (a) FROM t WINDOW w AS (PARTITION BY (b) ORDER BY (c)) -- fully parenthetized +SELECT a FROM t WINDOW w AS (PARTITION BY b ORDER BY c) -- literals removed +SELECT _ FROM _ WINDOW _ AS (PARTITION BY _ ORDER BY _) -- identifiers removed + +parse +SELECT avg(1) OVER w FROM t +---- +SELECT avg(1) OVER w FROM t +SELECT ((avg)((1)) OVER w) FROM t -- fully parenthetized +SELECT avg(_) OVER w FROM t -- literals removed +SELECT avg(1) OVER _ FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER () FROM t +---- +SELECT avg(1) OVER () FROM t +SELECT ((avg)((1)) OVER ()) FROM t -- fully parenthetized +SELECT avg(_) OVER () FROM t -- literals removed +SELECT avg(1) OVER () FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (w) FROM t +---- +SELECT avg(1) OVER (w) FROM t +SELECT ((avg)((1)) OVER (w)) FROM t -- fully parenthetized +SELECT avg(_) OVER (w) FROM t -- literals removed +SELECT avg(1) OVER (_) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (PARTITION BY b) FROM t +---- +SELECT avg(1) OVER (PARTITION BY b) FROM t +SELECT ((avg)((1)) OVER (PARTITION BY (b))) FROM t -- fully parenthetized +SELECT avg(_) OVER (PARTITION BY b) FROM t -- literals removed +SELECT avg(1) OVER (PARTITION BY _) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ORDER BY c) FROM t +---- +SELECT avg(1) OVER (ORDER BY c) FROM t +SELECT ((avg)((1)) OVER (ORDER BY (c))) FROM t -- fully parenthetized +SELECT avg(_) OVER (ORDER BY c) FROM t -- literals removed +SELECT avg(1) OVER (ORDER BY _) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (PARTITION BY b ORDER BY c) FROM t +---- +SELECT avg(1) OVER (PARTITION BY b ORDER BY c) FROM t +SELECT ((avg)((1)) OVER (PARTITION BY (b) ORDER BY (c))) FROM t -- fully parenthetized +SELECT avg(_) OVER (PARTITION BY b ORDER BY c) FROM t -- literals removed +SELECT avg(1) OVER (PARTITION BY _ ORDER BY _) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (w PARTITION BY b ORDER BY c) FROM t +---- +SELECT avg(1) OVER (w PARTITION BY b ORDER BY c) FROM t +SELECT ((avg)((1)) OVER (w PARTITION BY (b) ORDER BY (c))) FROM t -- fully parenthetized +SELECT avg(_) OVER (w PARTITION BY b ORDER BY c) FROM t -- literals removed +SELECT avg(1) OVER (_ PARTITION BY _ ORDER BY _) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ROWS UNBOUNDED PRECEDING) FROM t +---- +SELECT avg(1) OVER (ROWS UNBOUNDED PRECEDING) FROM t +SELECT ((avg)((1)) OVER (ROWS UNBOUNDED PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ROWS UNBOUNDED PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (ROWS UNBOUNDED PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ROWS 1 PRECEDING) FROM t +---- +SELECT avg(1) OVER (ROWS 1 PRECEDING) FROM t +SELECT ((avg)((1)) OVER (ROWS (1) PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ROWS _ PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (ROWS 1 PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ROWS CURRENT ROW) FROM t +---- +SELECT avg(1) OVER (ROWS CURRENT ROW) FROM t +SELECT ((avg)((1)) OVER (ROWS CURRENT ROW)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ROWS CURRENT ROW) FROM t -- literals removed +SELECT avg(1) OVER (ROWS CURRENT ROW) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) FROM t +---- +SELECT avg(1) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) FROM t +SELECT ((avg)((1)) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND (1) PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND _ PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t +---- +SELECT avg(1) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t +SELECT ((avg)((1)) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t -- literals removed +SELECT avg(1) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING) FROM t +---- +SELECT avg(1) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND (1) FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND _ FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t +---- +SELECT avg(1) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) FROM t +---- +SELECT avg(1) OVER (ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) FROM t +SELECT ((avg)((1)) OVER (ROWS BETWEEN (1) PRECEDING AND (1) PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ROWS BETWEEN _ PRECEDING AND _ PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) FROM t +---- +SELECT avg(1) OVER (ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) FROM t +SELECT ((avg)((1)) OVER (ROWS BETWEEN (1) PRECEDING AND CURRENT ROW)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ROWS BETWEEN _ PRECEDING AND CURRENT ROW) FROM t -- literals removed +SELECT avg(1) OVER (ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t +---- +SELECT avg(1) OVER (ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (ROWS BETWEEN (1) PRECEDING AND (1) FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ROWS BETWEEN _ PRECEDING AND _ FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ROWS BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING) FROM t +---- +SELECT avg(1) OVER (ROWS BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (ROWS BETWEEN (1) PRECEDING AND UNBOUNDED FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ROWS BETWEEN _ PRECEDING AND UNBOUNDED FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (ROWS BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t +---- +SELECT avg(1) OVER (ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t +SELECT ((avg)((1)) OVER (ROWS BETWEEN CURRENT ROW AND CURRENT ROW)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t -- literals removed +SELECT avg(1) OVER (ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM t +---- +SELECT avg(1) OVER (ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (ROWS BETWEEN CURRENT ROW AND (1) FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ROWS BETWEEN CURRENT ROW AND _ FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t +---- +SELECT avg(1) OVER (ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING) FROM t +---- +SELECT avg(1) OVER (ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (ROWS BETWEEN (1) FOLLOWING AND (1) FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ROWS BETWEEN _ FOLLOWING AND _ FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ROWS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t +---- +SELECT avg(1) OVER (ROWS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (ROWS BETWEEN (1) FOLLOWING AND UNBOUNDED FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ROWS BETWEEN _ FOLLOWING AND UNBOUNDED FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (ROWS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (w ROWS UNBOUNDED PRECEDING) FROM t +---- +SELECT avg(1) OVER (w ROWS UNBOUNDED PRECEDING) FROM t +SELECT ((avg)((1)) OVER (w ROWS UNBOUNDED PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (w ROWS UNBOUNDED PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (_ ROWS UNBOUNDED PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (PARTITION BY b ROWS UNBOUNDED PRECEDING) FROM t +---- +SELECT avg(1) OVER (PARTITION BY b ROWS UNBOUNDED PRECEDING) FROM t +SELECT ((avg)((1)) OVER (PARTITION BY (b) ROWS UNBOUNDED PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (PARTITION BY b ROWS UNBOUNDED PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (PARTITION BY _ ROWS UNBOUNDED PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ORDER BY c ROWS UNBOUNDED PRECEDING) FROM t +---- +SELECT avg(1) OVER (ORDER BY c ROWS UNBOUNDED PRECEDING) FROM t +SELECT ((avg)((1)) OVER (ORDER BY (c) ROWS UNBOUNDED PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ORDER BY c ROWS UNBOUNDED PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (ORDER BY _ ROWS UNBOUNDED PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (PARTITION BY b ORDER BY c ROWS UNBOUNDED PRECEDING) FROM t +---- +SELECT avg(1) OVER (PARTITION BY b ORDER BY c ROWS UNBOUNDED PRECEDING) FROM t +SELECT ((avg)((1)) OVER (PARTITION BY (b) ORDER BY (c) ROWS UNBOUNDED PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (PARTITION BY b ORDER BY c ROWS UNBOUNDED PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (PARTITION BY _ ORDER BY _ ROWS UNBOUNDED PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (w PARTITION BY b ORDER BY c ROWS UNBOUNDED PRECEDING) FROM t +---- +SELECT avg(1) OVER (w PARTITION BY b ORDER BY c ROWS UNBOUNDED PRECEDING) FROM t +SELECT ((avg)((1)) OVER (w PARTITION BY (b) ORDER BY (c) ROWS UNBOUNDED PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (w PARTITION BY b ORDER BY c ROWS UNBOUNDED PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (_ PARTITION BY _ ORDER BY _ ROWS UNBOUNDED PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (RANGE UNBOUNDED PRECEDING) FROM t +---- +SELECT avg(1) OVER (RANGE UNBOUNDED PRECEDING) FROM t +SELECT ((avg)((1)) OVER (RANGE UNBOUNDED PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (RANGE UNBOUNDED PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (RANGE UNBOUNDED PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (RANGE 1 PRECEDING) FROM t +---- +SELECT avg(1) OVER (RANGE 1 PRECEDING) FROM t +SELECT ((avg)((1)) OVER (RANGE (1) PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (RANGE _ PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (RANGE 1 PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (RANGE CURRENT ROW) FROM t +---- +SELECT avg(1) OVER (RANGE CURRENT ROW) FROM t +SELECT ((avg)((1)) OVER (RANGE CURRENT ROW)) FROM t -- fully parenthetized +SELECT avg(_) OVER (RANGE CURRENT ROW) FROM t -- literals removed +SELECT avg(1) OVER (RANGE CURRENT ROW) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) FROM t +---- +SELECT avg(1) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) FROM t +SELECT ((avg)((1)) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND (1) PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND _ PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t +---- +SELECT avg(1) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t +SELECT ((avg)((1)) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) FROM t -- fully parenthetized +SELECT avg(_) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t -- literals removed +SELECT avg(1) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING) FROM t +---- +SELECT avg(1) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND (1) FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND _ FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t +---- +SELECT avg(1) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (RANGE BETWEEN 1 PRECEDING AND 1 PRECEDING) FROM t +---- +SELECT avg(1) OVER (RANGE BETWEEN 1 PRECEDING AND 1 PRECEDING) FROM t +SELECT ((avg)((1)) OVER (RANGE BETWEEN (1) PRECEDING AND (1) PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (RANGE BETWEEN _ PRECEDING AND _ PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (RANGE BETWEEN 1 PRECEDING AND 1 PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (RANGE BETWEEN 1 PRECEDING AND CURRENT ROW) FROM t +---- +SELECT avg(1) OVER (RANGE BETWEEN 1 PRECEDING AND CURRENT ROW) FROM t +SELECT ((avg)((1)) OVER (RANGE BETWEEN (1) PRECEDING AND CURRENT ROW)) FROM t -- fully parenthetized +SELECT avg(_) OVER (RANGE BETWEEN _ PRECEDING AND CURRENT ROW) FROM t -- literals removed +SELECT avg(1) OVER (RANGE BETWEEN 1 PRECEDING AND CURRENT ROW) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t +---- +SELECT avg(1) OVER (RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (RANGE BETWEEN (1) PRECEDING AND (1) FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (RANGE BETWEEN _ PRECEDING AND _ FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (RANGE BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING) FROM t +---- +SELECT avg(1) OVER (RANGE BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (RANGE BETWEEN (1) PRECEDING AND UNBOUNDED FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (RANGE BETWEEN _ PRECEDING AND UNBOUNDED FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (RANGE BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t +---- +SELECT avg(1) OVER (RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t +SELECT ((avg)((1)) OVER (RANGE BETWEEN CURRENT ROW AND CURRENT ROW)) FROM t -- fully parenthetized +SELECT avg(_) OVER (RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM t -- literals removed +SELECT avg(1) OVER (RANGE BETWEEN CURRENT ROW AND CURRENT ROW) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (RANGE BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM t +---- +SELECT avg(1) OVER (RANGE BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (RANGE BETWEEN CURRENT ROW AND (1) FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (RANGE BETWEEN CURRENT ROW AND _ FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (RANGE BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t +---- +SELECT avg(1) OVER (RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (RANGE BETWEEN 1 FOLLOWING AND 1 FOLLOWING) FROM t +---- +SELECT avg(1) OVER (RANGE BETWEEN 1 FOLLOWING AND 1 FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (RANGE BETWEEN (1) FOLLOWING AND (1) FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (RANGE BETWEEN _ FOLLOWING AND _ FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (RANGE BETWEEN 1 FOLLOWING AND 1 FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (RANGE BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t +---- +SELECT avg(1) OVER (RANGE BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (RANGE BETWEEN (1) FOLLOWING AND UNBOUNDED FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (RANGE BETWEEN _ FOLLOWING AND UNBOUNDED FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (RANGE BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (w RANGE UNBOUNDED PRECEDING) FROM t +---- +SELECT avg(1) OVER (w RANGE UNBOUNDED PRECEDING) FROM t +SELECT ((avg)((1)) OVER (w RANGE UNBOUNDED PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (w RANGE UNBOUNDED PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (_ RANGE UNBOUNDED PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (PARTITION BY b RANGE UNBOUNDED PRECEDING) FROM t +---- +SELECT avg(1) OVER (PARTITION BY b RANGE UNBOUNDED PRECEDING) FROM t +SELECT ((avg)((1)) OVER (PARTITION BY (b) RANGE UNBOUNDED PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (PARTITION BY b RANGE UNBOUNDED PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (PARTITION BY _ RANGE UNBOUNDED PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ORDER BY c RANGE UNBOUNDED PRECEDING) FROM t +---- +SELECT avg(1) OVER (ORDER BY c RANGE UNBOUNDED PRECEDING) FROM t +SELECT ((avg)((1)) OVER (ORDER BY (c) RANGE UNBOUNDED PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ORDER BY c RANGE UNBOUNDED PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (ORDER BY _ RANGE UNBOUNDED PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (PARTITION BY b ORDER BY c RANGE UNBOUNDED PRECEDING) FROM t +---- +SELECT avg(1) OVER (PARTITION BY b ORDER BY c RANGE UNBOUNDED PRECEDING) FROM t +SELECT ((avg)((1)) OVER (PARTITION BY (b) ORDER BY (c) RANGE UNBOUNDED PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (PARTITION BY b ORDER BY c RANGE UNBOUNDED PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (PARTITION BY _ ORDER BY _ RANGE UNBOUNDED PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (w PARTITION BY b ORDER BY c RANGE UNBOUNDED PRECEDING) FROM t +---- +SELECT avg(1) OVER (w PARTITION BY b ORDER BY c RANGE UNBOUNDED PRECEDING) FROM t +SELECT ((avg)((1)) OVER (w PARTITION BY (b) ORDER BY (c) RANGE UNBOUNDED PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (w PARTITION BY b ORDER BY c RANGE UNBOUNDED PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (_ PARTITION BY _ ORDER BY _ RANGE UNBOUNDED PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (GROUPS UNBOUNDED PRECEDING) FROM t +---- +SELECT avg(1) OVER (GROUPS UNBOUNDED PRECEDING) FROM t +SELECT ((avg)((1)) OVER (GROUPS UNBOUNDED PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (GROUPS UNBOUNDED PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (GROUPS UNBOUNDED PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (GROUPS 1 PRECEDING) FROM t +---- +SELECT avg(1) OVER (GROUPS 1 PRECEDING) FROM t +SELECT ((avg)((1)) OVER (GROUPS (1) PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (GROUPS _ PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (GROUPS 1 PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (GROUPS CURRENT ROW) FROM t +---- +SELECT avg(1) OVER (GROUPS CURRENT ROW) FROM t +SELECT ((avg)((1)) OVER (GROUPS CURRENT ROW)) FROM t -- fully parenthetized +SELECT avg(_) OVER (GROUPS CURRENT ROW) FROM t -- literals removed +SELECT avg(1) OVER (GROUPS CURRENT ROW) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) FROM t +---- +SELECT avg(1) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) FROM t +SELECT ((avg)((1)) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND (1) PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND _ PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t +---- +SELECT avg(1) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t +SELECT ((avg)((1)) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) FROM t -- fully parenthetized +SELECT avg(_) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t -- literals removed +SELECT avg(1) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING) FROM t +---- +SELECT avg(1) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND (1) FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND _ FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t +---- +SELECT avg(1) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (GROUPS BETWEEN 1 PRECEDING AND 1 PRECEDING) FROM t +---- +SELECT avg(1) OVER (GROUPS BETWEEN 1 PRECEDING AND 1 PRECEDING) FROM t +SELECT ((avg)((1)) OVER (GROUPS BETWEEN (1) PRECEDING AND (1) PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (GROUPS BETWEEN _ PRECEDING AND _ PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (GROUPS BETWEEN 1 PRECEDING AND 1 PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (GROUPS BETWEEN 1 PRECEDING AND CURRENT ROW) FROM t +---- +SELECT avg(1) OVER (GROUPS BETWEEN 1 PRECEDING AND CURRENT ROW) FROM t +SELECT ((avg)((1)) OVER (GROUPS BETWEEN (1) PRECEDING AND CURRENT ROW)) FROM t -- fully parenthetized +SELECT avg(_) OVER (GROUPS BETWEEN _ PRECEDING AND CURRENT ROW) FROM t -- literals removed +SELECT avg(1) OVER (GROUPS BETWEEN 1 PRECEDING AND CURRENT ROW) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (GROUPS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t +---- +SELECT avg(1) OVER (GROUPS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (GROUPS BETWEEN (1) PRECEDING AND (1) FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (GROUPS BETWEEN _ PRECEDING AND _ FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (GROUPS BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (GROUPS BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING) FROM t +---- +SELECT avg(1) OVER (GROUPS BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (GROUPS BETWEEN (1) PRECEDING AND UNBOUNDED FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (GROUPS BETWEEN _ PRECEDING AND UNBOUNDED FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (GROUPS BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (GROUPS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t +---- +SELECT avg(1) OVER (GROUPS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t +SELECT ((avg)((1)) OVER (GROUPS BETWEEN CURRENT ROW AND CURRENT ROW)) FROM t -- fully parenthetized +SELECT avg(_) OVER (GROUPS BETWEEN CURRENT ROW AND CURRENT ROW) FROM t -- literals removed +SELECT avg(1) OVER (GROUPS BETWEEN CURRENT ROW AND CURRENT ROW) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (GROUPS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM t +---- +SELECT avg(1) OVER (GROUPS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (GROUPS BETWEEN CURRENT ROW AND (1) FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (GROUPS BETWEEN CURRENT ROW AND _ FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (GROUPS BETWEEN CURRENT ROW AND 1 FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t +---- +SELECT avg(1) OVER (GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (GROUPS BETWEEN 1 FOLLOWING AND 1 FOLLOWING) FROM t +---- +SELECT avg(1) OVER (GROUPS BETWEEN 1 FOLLOWING AND 1 FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (GROUPS BETWEEN (1) FOLLOWING AND (1) FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (GROUPS BETWEEN _ FOLLOWING AND _ FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (GROUPS BETWEEN 1 FOLLOWING AND 1 FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (GROUPS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t +---- +SELECT avg(1) OVER (GROUPS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING) FROM t +SELECT ((avg)((1)) OVER (GROUPS BETWEEN (1) FOLLOWING AND UNBOUNDED FOLLOWING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (GROUPS BETWEEN _ FOLLOWING AND UNBOUNDED FOLLOWING) FROM t -- literals removed +SELECT avg(1) OVER (GROUPS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (w GROUPS UNBOUNDED PRECEDING) FROM t +---- +SELECT avg(1) OVER (w GROUPS UNBOUNDED PRECEDING) FROM t +SELECT ((avg)((1)) OVER (w GROUPS UNBOUNDED PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (w GROUPS UNBOUNDED PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (_ GROUPS UNBOUNDED PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (PARTITION BY b GROUPS UNBOUNDED PRECEDING) FROM t +---- +SELECT avg(1) OVER (PARTITION BY b GROUPS UNBOUNDED PRECEDING) FROM t +SELECT ((avg)((1)) OVER (PARTITION BY (b) GROUPS UNBOUNDED PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (PARTITION BY b GROUPS UNBOUNDED PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (PARTITION BY _ GROUPS UNBOUNDED PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ORDER BY c GROUPS UNBOUNDED PRECEDING) FROM t +---- +SELECT avg(1) OVER (ORDER BY c GROUPS UNBOUNDED PRECEDING) FROM t +SELECT ((avg)((1)) OVER (ORDER BY (c) GROUPS UNBOUNDED PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ORDER BY c GROUPS UNBOUNDED PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (ORDER BY _ GROUPS UNBOUNDED PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (PARTITION BY b ORDER BY c GROUPS UNBOUNDED PRECEDING) FROM t +---- +SELECT avg(1) OVER (PARTITION BY b ORDER BY c GROUPS UNBOUNDED PRECEDING) FROM t +SELECT ((avg)((1)) OVER (PARTITION BY (b) ORDER BY (c) GROUPS UNBOUNDED PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (PARTITION BY b ORDER BY c GROUPS UNBOUNDED PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (PARTITION BY _ ORDER BY _ GROUPS UNBOUNDED PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (w PARTITION BY b ORDER BY c GROUPS UNBOUNDED PRECEDING) FROM t +---- +SELECT avg(1) OVER (w PARTITION BY b ORDER BY c GROUPS UNBOUNDED PRECEDING) FROM t +SELECT ((avg)((1)) OVER (w PARTITION BY (b) ORDER BY (c) GROUPS UNBOUNDED PRECEDING)) FROM t -- fully parenthetized +SELECT avg(_) OVER (w PARTITION BY b ORDER BY c GROUPS UNBOUNDED PRECEDING) FROM t -- literals removed +SELECT avg(1) OVER (_ PARTITION BY _ ORDER BY _ GROUPS UNBOUNDED PRECEDING) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ROWS UNBOUNDED PRECEDING EXCLUDE CURRENT ROW) FROM t +---- +SELECT avg(1) OVER (ROWS UNBOUNDED PRECEDING EXCLUDE CURRENT ROW) FROM t +SELECT ((avg)((1)) OVER (ROWS UNBOUNDED PRECEDING EXCLUDE CURRENT ROW)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ROWS UNBOUNDED PRECEDING EXCLUDE CURRENT ROW) FROM t -- literals removed +SELECT avg(1) OVER (ROWS UNBOUNDED PRECEDING EXCLUDE CURRENT ROW) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ROWS UNBOUNDED PRECEDING EXCLUDE GROUP) FROM t +---- +SELECT avg(1) OVER (ROWS UNBOUNDED PRECEDING EXCLUDE GROUP) FROM t +SELECT ((avg)((1)) OVER (ROWS UNBOUNDED PRECEDING EXCLUDE GROUP)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ROWS UNBOUNDED PRECEDING EXCLUDE GROUP) FROM t -- literals removed +SELECT avg(1) OVER (ROWS UNBOUNDED PRECEDING EXCLUDE GROUP) FROM _ -- identifiers removed + +parse +SELECT avg(1) OVER (ROWS UNBOUNDED PRECEDING EXCLUDE TIES) FROM t +---- +SELECT avg(1) OVER (ROWS UNBOUNDED PRECEDING EXCLUDE TIES) FROM t +SELECT ((avg)((1)) OVER (ROWS UNBOUNDED PRECEDING EXCLUDE TIES)) FROM t -- fully parenthetized +SELECT avg(_) OVER (ROWS UNBOUNDED PRECEDING EXCLUDE TIES) FROM t -- literals removed +SELECT avg(1) OVER (ROWS UNBOUNDED PRECEDING EXCLUDE TIES) FROM _ -- identifiers removed + +parse +SELECT percentile_disc(0.50) WITHIN GROUP (ORDER BY c) FROM t +---- +SELECT percentile_disc(0.50) WITHIN GROUP (ORDER BY c) FROM t +SELECT ((percentile_disc)((0.50)) WITHIN GROUP (ORDER BY (c))) FROM t -- fully parenthetized +SELECT percentile_disc(_) WITHIN GROUP (ORDER BY c) FROM t -- literals removed +SELECT percentile_disc(0.50) WITHIN GROUP (ORDER BY _) FROM _ -- identifiers removed + +parse +SELECT percentile_disc(0.50) WITHIN GROUP (ORDER BY c DESC) FROM t +---- +SELECT percentile_disc(0.50) WITHIN GROUP (ORDER BY c DESC) FROM t +SELECT ((percentile_disc)((0.50)) WITHIN GROUP (ORDER BY (c) DESC)) FROM t -- fully parenthetized +SELECT percentile_disc(_) WITHIN GROUP (ORDER BY c DESC) FROM t -- literals removed +SELECT percentile_disc(0.50) WITHIN GROUP (ORDER BY _ DESC) FROM _ -- identifiers removed + +parse +SELECT percentile_cont(0.50) WITHIN GROUP (ORDER BY c) FROM t +---- +SELECT percentile_cont(0.50) WITHIN GROUP (ORDER BY c) FROM t +SELECT ((percentile_cont)((0.50)) WITHIN GROUP (ORDER BY (c))) FROM t -- fully parenthetized +SELECT percentile_cont(_) WITHIN GROUP (ORDER BY c) FROM t -- literals removed +SELECT percentile_cont(0.50) WITHIN GROUP (ORDER BY _) FROM _ -- identifiers removed + +parse +SELECT percentile_disc(ARRAY[0.95, 0.90]) WITHIN GROUP (ORDER BY c) FROM t +---- +SELECT percentile_disc(ARRAY[0.95, 0.90]) WITHIN GROUP (ORDER BY c) FROM t +SELECT ((percentile_disc)((ARRAY[(0.95), (0.90)])) WITHIN GROUP (ORDER BY (c))) FROM t -- fully parenthetized +SELECT percentile_disc(ARRAY[_, _]) WITHIN GROUP (ORDER BY c) FROM t -- literals removed +SELECT percentile_disc(ARRAY[0.95, 0.90]) WITHIN GROUP (ORDER BY _) FROM _ -- identifiers removed + +parse +SELECT percentile_cont(ARRAY[0.95, 0.90]) WITHIN GROUP (ORDER BY c) FROM t +---- +SELECT percentile_cont(ARRAY[0.95, 0.90]) WITHIN GROUP (ORDER BY c) FROM t +SELECT ((percentile_cont)((ARRAY[(0.95), (0.90)])) WITHIN GROUP (ORDER BY (c))) FROM t -- fully parenthetized +SELECT percentile_cont(ARRAY[_, _]) WITHIN GROUP (ORDER BY c) FROM t -- literals removed +SELECT percentile_cont(ARRAY[0.95, 0.90]) WITHIN GROUP (ORDER BY _) FROM _ -- identifiers removed + +parse +SELECT avg(1) FILTER (WHERE a > b) +---- +SELECT avg(1) FILTER (WHERE a > b) +SELECT ((avg)((1)) FILTER (WHERE ((a) > (b)))) -- fully parenthetized +SELECT avg(_) FILTER (WHERE a > b) -- literals removed +SELECT avg(1) FILTER (WHERE _ > _) -- identifiers removed + +parse +SELECT avg(1) FILTER (WHERE a > b) OVER (ORDER BY c) +---- +SELECT avg(1) FILTER (WHERE a > b) OVER (ORDER BY c) +SELECT ((avg)((1)) FILTER (WHERE ((a) > (b))) OVER (ORDER BY (c))) -- fully parenthetized +SELECT avg(_) FILTER (WHERE a > b) OVER (ORDER BY c) -- literals removed +SELECT avg(1) FILTER (WHERE _ > _) OVER (ORDER BY _) -- identifiers removed + +parse +SELECT a FROM t UNION SELECT 1 FROM t +---- +SELECT a FROM t UNION SELECT 1 FROM t +SELECT (a) FROM t UNION SELECT (1) FROM t -- fully parenthetized +SELECT a FROM t UNION SELECT _ FROM t -- literals removed +SELECT _ FROM _ UNION SELECT 1 FROM _ -- identifiers removed + +parse +SELECT a FROM t UNION SELECT 1 FROM t UNION SELECT 1 FROM t +---- +SELECT a FROM t UNION SELECT 1 FROM t UNION SELECT 1 FROM t +SELECT (a) FROM t UNION SELECT (1) FROM t UNION SELECT (1) FROM t -- fully parenthetized +SELECT a FROM t UNION SELECT _ FROM t UNION SELECT _ FROM t -- literals removed +SELECT _ FROM _ UNION SELECT 1 FROM _ UNION SELECT 1 FROM _ -- identifiers removed + +parse +SELECT a FROM t UNION ALL SELECT 1 FROM t +---- +SELECT a FROM t UNION ALL SELECT 1 FROM t +SELECT (a) FROM t UNION ALL SELECT (1) FROM t -- fully parenthetized +SELECT a FROM t UNION ALL SELECT _ FROM t -- literals removed +SELECT _ FROM _ UNION ALL SELECT 1 FROM _ -- identifiers removed + +parse +SELECT a FROM t UNION DISTINCT SELECT 1 FROM t +---- +SELECT a FROM t UNION SELECT 1 FROM t -- normalized! +SELECT (a) FROM t UNION SELECT (1) FROM t -- fully parenthetized +SELECT a FROM t UNION SELECT _ FROM t -- literals removed +SELECT _ FROM _ UNION SELECT 1 FROM _ -- identifiers removed + + +parse +SELECT a FROM t EXCEPT SELECT 1 FROM t +---- +SELECT a FROM t EXCEPT SELECT 1 FROM t +SELECT (a) FROM t EXCEPT SELECT (1) FROM t -- fully parenthetized +SELECT a FROM t EXCEPT SELECT _ FROM t -- literals removed +SELECT _ FROM _ EXCEPT SELECT 1 FROM _ -- identifiers removed + +parse +SELECT a FROM t EXCEPT ALL SELECT 1 FROM t +---- +SELECT a FROM t EXCEPT ALL SELECT 1 FROM t +SELECT (a) FROM t EXCEPT ALL SELECT (1) FROM t -- fully parenthetized +SELECT a FROM t EXCEPT ALL SELECT _ FROM t -- literals removed +SELECT _ FROM _ EXCEPT ALL SELECT 1 FROM _ -- identifiers removed + +parse +SELECT a FROM t EXCEPT DISTINCT SELECT 1 FROM t +---- +SELECT a FROM t EXCEPT SELECT 1 FROM t -- normalized! +SELECT (a) FROM t EXCEPT SELECT (1) FROM t -- fully parenthetized +SELECT a FROM t EXCEPT SELECT _ FROM t -- literals removed +SELECT _ FROM _ EXCEPT SELECT 1 FROM _ -- identifiers removed + +parse +SELECT a FROM t INTERSECT SELECT 1 FROM t +---- +SELECT a FROM t INTERSECT SELECT 1 FROM t +SELECT (a) FROM t INTERSECT SELECT (1) FROM t -- fully parenthetized +SELECT a FROM t INTERSECT SELECT _ FROM t -- literals removed +SELECT _ FROM _ INTERSECT SELECT 1 FROM _ -- identifiers removed + +parse +SELECT a FROM t INTERSECT ALL SELECT 1 FROM t +---- +SELECT a FROM t INTERSECT ALL SELECT 1 FROM t +SELECT (a) FROM t INTERSECT ALL SELECT (1) FROM t -- fully parenthetized +SELECT a FROM t INTERSECT ALL SELECT _ FROM t -- literals removed +SELECT _ FROM _ INTERSECT ALL SELECT 1 FROM _ -- identifiers removed + +parse +SELECT a FROM t INTERSECT DISTINCT SELECT 1 FROM t +---- +SELECT a FROM t INTERSECT SELECT 1 FROM t -- normalized! +SELECT (a) FROM t INTERSECT SELECT (1) FROM t -- fully parenthetized +SELECT a FROM t INTERSECT SELECT _ FROM t -- literals removed +SELECT _ FROM _ INTERSECT SELECT 1 FROM _ -- identifiers removed + +parse +SELECT a FROM t1 JOIN t2 ON a = b +---- +SELECT a FROM t1 JOIN t2 ON a = b +SELECT (a) FROM t1 JOIN t2 ON ((a) = (b)) -- fully parenthetized +SELECT a FROM t1 JOIN t2 ON a = b -- literals removed +SELECT _ FROM _ JOIN _ ON _ = _ -- identifiers removed + +parse +SELECT a FROM t1 JOIN t2 USING (a) +---- +SELECT a FROM t1 JOIN t2 USING (a) +SELECT (a) FROM t1 JOIN t2 USING (a) -- fully parenthetized +SELECT a FROM t1 JOIN t2 USING (a) -- literals removed +SELECT _ FROM _ JOIN _ USING (_) -- identifiers removed + +parse +SELECT a FROM t1 INNER MERGE JOIN t2 USING (a) +---- +SELECT a FROM t1 INNER MERGE JOIN t2 USING (a) +SELECT (a) FROM t1 INNER MERGE JOIN t2 USING (a) -- fully parenthetized +SELECT a FROM t1 INNER MERGE JOIN t2 USING (a) -- literals removed +SELECT _ FROM _ INNER MERGE JOIN _ USING (_) -- identifiers removed + +parse +SELECT a FROM t1 LEFT JOIN t2 ON a = b +---- +SELECT a FROM t1 LEFT JOIN t2 ON a = b +SELECT (a) FROM t1 LEFT JOIN t2 ON ((a) = (b)) -- fully parenthetized +SELECT a FROM t1 LEFT JOIN t2 ON a = b -- literals removed +SELECT _ FROM _ LEFT JOIN _ ON _ = _ -- identifiers removed + +parse +SELECT a FROM t1 LEFT OUTER JOIN t2 ON a = b +---- +SELECT a FROM t1 LEFT JOIN t2 ON a = b -- normalized! +SELECT (a) FROM t1 LEFT JOIN t2 ON ((a) = (b)) -- fully parenthetized +SELECT a FROM t1 LEFT JOIN t2 ON a = b -- literals removed +SELECT _ FROM _ LEFT JOIN _ ON _ = _ -- identifiers removed + +parse +SELECT a FROM t1 LEFT LOOKUP JOIN t2 ON a = b +---- +SELECT a FROM t1 LEFT LOOKUP JOIN t2 ON a = b +SELECT (a) FROM t1 LEFT LOOKUP JOIN t2 ON ((a) = (b)) -- fully parenthetized +SELECT a FROM t1 LEFT LOOKUP JOIN t2 ON a = b -- literals removed +SELECT _ FROM _ LEFT LOOKUP JOIN _ ON _ = _ -- identifiers removed + +parse +SELECT a FROM t1 LEFT INVERTED JOIN t2 ON a @> b +---- +SELECT a FROM t1 LEFT INVERTED JOIN t2 ON a @> b +SELECT (a) FROM t1 LEFT INVERTED JOIN t2 ON ((a) @> (b)) -- fully parenthetized +SELECT a FROM t1 LEFT INVERTED JOIN t2 ON a @> b -- literals removed +SELECT _ FROM _ LEFT INVERTED JOIN _ ON _ @> _ -- identifiers removed + +parse +SELECT a FROM t1 RIGHT JOIN t2 ON a = b +---- +SELECT a FROM t1 RIGHT JOIN t2 ON a = b +SELECT (a) FROM t1 RIGHT JOIN t2 ON ((a) = (b)) -- fully parenthetized +SELECT a FROM t1 RIGHT JOIN t2 ON a = b -- literals removed +SELECT _ FROM _ RIGHT JOIN _ ON _ = _ -- identifiers removed + +parse +SELECT a FROM t1 RIGHT OUTER JOIN t2 ON a = b +---- +SELECT a FROM t1 RIGHT JOIN t2 ON a = b -- normalized! +SELECT (a) FROM t1 RIGHT JOIN t2 ON ((a) = (b)) -- fully parenthetized +SELECT a FROM t1 RIGHT JOIN t2 ON a = b -- literals removed +SELECT _ FROM _ RIGHT JOIN _ ON _ = _ -- identifiers removed + +parse +SELECT a FROM t1 RIGHT OUTER MERGE JOIN t2 ON a = b +---- +SELECT a FROM t1 RIGHT MERGE JOIN t2 ON a = b -- normalized! +SELECT (a) FROM t1 RIGHT MERGE JOIN t2 ON ((a) = (b)) -- fully parenthetized +SELECT a FROM t1 RIGHT MERGE JOIN t2 ON a = b -- literals removed +SELECT _ FROM _ RIGHT MERGE JOIN _ ON _ = _ -- identifiers removed + + +parse +SELECT a FROM t1 INNER JOIN t2 ON a = b +---- +SELECT a FROM t1 INNER JOIN t2 ON a = b +SELECT (a) FROM t1 INNER JOIN t2 ON ((a) = (b)) -- fully parenthetized +SELECT a FROM t1 INNER JOIN t2 ON a = b -- literals removed +SELECT _ FROM _ INNER JOIN _ ON _ = _ -- identifiers removed + +parse +SELECT a FROM t1 INNER HASH JOIN t2 ON a = b +---- +SELECT a FROM t1 INNER HASH JOIN t2 ON a = b +SELECT (a) FROM t1 INNER HASH JOIN t2 ON ((a) = (b)) -- fully parenthetized +SELECT a FROM t1 INNER HASH JOIN t2 ON a = b -- literals removed +SELECT _ FROM _ INNER HASH JOIN _ ON _ = _ -- identifiers removed + +parse +SELECT a FROM t1 CROSS JOIN t2 +---- +SELECT a FROM t1 CROSS JOIN t2 +SELECT (a) FROM t1 CROSS JOIN t2 -- fully parenthetized +SELECT a FROM t1 CROSS JOIN t2 -- literals removed +SELECT _ FROM _ CROSS JOIN _ -- identifiers removed + +parse +SELECT a FROM t1 CROSS LOOKUP JOIN t2 +---- +SELECT a FROM t1 CROSS LOOKUP JOIN t2 +SELECT (a) FROM t1 CROSS LOOKUP JOIN t2 -- fully parenthetized +SELECT a FROM t1 CROSS LOOKUP JOIN t2 -- literals removed +SELECT _ FROM _ CROSS LOOKUP JOIN _ -- identifiers removed + +parse +SELECT a FROM t1 CROSS INVERTED JOIN t2 +---- +SELECT a FROM t1 CROSS INVERTED JOIN t2 +SELECT (a) FROM t1 CROSS INVERTED JOIN t2 -- fully parenthetized +SELECT a FROM t1 CROSS INVERTED JOIN t2 -- literals removed +SELECT _ FROM _ CROSS INVERTED JOIN _ -- identifiers removed + +parse +SELECT a FROM t1 NATURAL JOIN t2 +---- +SELECT a FROM t1 NATURAL JOIN t2 +SELECT (a) FROM t1 NATURAL JOIN t2 -- fully parenthetized +SELECT a FROM t1 NATURAL JOIN t2 -- literals removed +SELECT _ FROM _ NATURAL JOIN _ -- identifiers removed + +parse +SELECT a FROM t1 NATURAL INNER MERGE JOIN t2 +---- +SELECT a FROM t1 NATURAL INNER MERGE JOIN t2 +SELECT (a) FROM t1 NATURAL INNER MERGE JOIN t2 -- fully parenthetized +SELECT a FROM t1 NATURAL INNER MERGE JOIN t2 -- literals removed +SELECT _ FROM _ NATURAL INNER MERGE JOIN _ -- identifiers removed + +parse +SELECT a FROM t1 INNER JOIN t2 USING (a) +---- +SELECT a FROM t1 INNER JOIN t2 USING (a) +SELECT (a) FROM t1 INNER JOIN t2 USING (a) -- fully parenthetized +SELECT a FROM t1 INNER JOIN t2 USING (a) -- literals removed +SELECT _ FROM _ INNER JOIN _ USING (_) -- identifiers removed + +parse +SELECT a FROM t1 FULL JOIN t2 USING (a) +---- +SELECT a FROM t1 FULL JOIN t2 USING (a) +SELECT (a) FROM t1 FULL JOIN t2 USING (a) -- fully parenthetized +SELECT a FROM t1 FULL JOIN t2 USING (a) -- literals removed +SELECT _ FROM _ FULL JOIN _ USING (_) -- identifiers removed + +parse +SELECT a FROM t1 FULL MERGE JOIN t2 USING (a) +---- +SELECT a FROM t1 FULL MERGE JOIN t2 USING (a) +SELECT (a) FROM t1 FULL MERGE JOIN t2 USING (a) -- fully parenthetized +SELECT a FROM t1 FULL MERGE JOIN t2 USING (a) -- literals removed +SELECT _ FROM _ FULL MERGE JOIN _ USING (_) -- identifiers removed + +parse +SELECT * FROM (t1 WITH ORDINALITY AS o1 CROSS JOIN t2 WITH ORDINALITY AS o2) WITH ORDINALITY AS o3 +---- +SELECT * FROM (t1 WITH ORDINALITY AS o1 CROSS JOIN t2 WITH ORDINALITY AS o2) WITH ORDINALITY AS o3 +SELECT (*) FROM (t1 WITH ORDINALITY AS o1 CROSS JOIN t2 WITH ORDINALITY AS o2) WITH ORDINALITY AS o3 -- fully parenthetized +SELECT * FROM (t1 WITH ORDINALITY AS o1 CROSS JOIN t2 WITH ORDINALITY AS o2) WITH ORDINALITY AS o3 -- literals removed +SELECT * FROM (_ WITH ORDINALITY AS _ CROSS JOIN _ WITH ORDINALITY AS _) WITH ORDINALITY AS _ -- identifiers removed + +parse +SELECT a FROM t1 AS OF SYSTEM TIME '2016-01-01' +---- +SELECT a FROM t1 AS OF SYSTEM TIME '2016-01-01' +SELECT (a) FROM t1 AS OF SYSTEM TIME ('2016-01-01') -- fully parenthetized +SELECT a FROM t1 AS OF SYSTEM TIME _ -- literals removed +SELECT _ FROM _ AS OF SYSTEM TIME '2016-01-01' -- identifiers removed + +parse +SELECT a FROM t1, t2 AS OF SYSTEM TIME '2016-01-01' +---- +SELECT a FROM t1, t2 AS OF SYSTEM TIME '2016-01-01' +SELECT (a) FROM t1, t2 AS OF SYSTEM TIME ('2016-01-01') -- fully parenthetized +SELECT a FROM t1, t2 AS OF SYSTEM TIME _ -- literals removed +SELECT _ FROM _, _ AS OF SYSTEM TIME '2016-01-01' -- identifiers removed + +parse +SELECT a FROM t1 AS OF SYSTEM TIME -('a' || 'b')::INTERVAL +---- +SELECT a FROM t1 AS OF SYSTEM TIME -('a' || 'b')::INTERVAL +SELECT (a) FROM t1 AS OF SYSTEM TIME (-((((('a') || ('b'))))::INTERVAL)) -- fully parenthetized +SELECT a FROM t1 AS OF SYSTEM TIME -(_ || _)::INTERVAL -- literals removed +SELECT _ FROM _ AS OF SYSTEM TIME -('a' || 'b')::INTERVAL -- identifiers removed + +parse +SELECT * FROM t LIMIT ALL +---- +SELECT * FROM t LIMIT ALL +SELECT (*) FROM t LIMIT ALL -- fully parenthetized +SELECT * FROM t LIMIT ALL -- literals removed +SELECT * FROM _ LIMIT ALL -- identifiers removed + +parse +SELECT EXISTS ((((TABLE error FOR KEY SHARE)) LIMIT ALL FOR KEY SHARE)) AS is FROM ident +---- +SELECT EXISTS ((((TABLE error FOR KEY SHARE)) LIMIT ALL FOR KEY SHARE)) AS is FROM ident +SELECT (EXISTS ((((TABLE error FOR KEY SHARE)) LIMIT ALL FOR KEY SHARE))) AS is FROM ident -- fully parenthetized +SELECT EXISTS ((((TABLE error FOR KEY SHARE)) LIMIT ALL FOR KEY SHARE)) AS is FROM ident -- literals removed +SELECT EXISTS ((((TABLE _ FOR KEY SHARE)) LIMIT ALL FOR KEY SHARE)) AS _ FROM _ -- identifiers removed + +parse +SELECT a FROM t LIMIT a +---- +SELECT a FROM t LIMIT a +SELECT (a) FROM t LIMIT (a) -- fully parenthetized +SELECT a FROM t LIMIT a -- literals removed +SELECT _ FROM _ LIMIT _ -- identifiers removed + +parse +SELECT a FROM t OFFSET b +---- +SELECT a FROM t OFFSET b +SELECT (a) FROM t OFFSET (b) -- fully parenthetized +SELECT a FROM t OFFSET b -- literals removed +SELECT _ FROM _ OFFSET _ -- identifiers removed + +parse +SELECT a FROM t LIMIT a OFFSET b +---- +SELECT a FROM t LIMIT a OFFSET b +SELECT (a) FROM t LIMIT (a) OFFSET (b) -- fully parenthetized +SELECT a FROM t LIMIT a OFFSET b -- literals removed +SELECT _ FROM _ LIMIT _ OFFSET _ -- identifiers removed + +parse +SELECT a FROM t1 OFFSET a ROW +---- +SELECT a FROM t1 OFFSET a -- normalized! +SELECT (a) FROM t1 OFFSET (a) -- fully parenthetized +SELECT a FROM t1 OFFSET a -- literals removed +SELECT _ FROM _ OFFSET _ -- identifiers removed + +parse +SELECT a FROM t1 OFFSET a ROWS +---- +SELECT a FROM t1 OFFSET a -- normalized! +SELECT (a) FROM t1 OFFSET (a) -- fully parenthetized +SELECT a FROM t1 OFFSET a -- literals removed +SELECT _ FROM _ OFFSET _ -- identifiers removed + +parse +SELECT a FROM t OFFSET a LIMIT b +---- +SELECT a FROM t LIMIT b OFFSET a -- normalized! +SELECT (a) FROM t LIMIT (b) OFFSET (a) -- fully parenthetized +SELECT a FROM t LIMIT b OFFSET a -- literals removed +SELECT _ FROM _ LIMIT _ OFFSET _ -- identifiers removed + +parse +SELECT a FROM t FETCH FIRST 3 ROWS ONLY +---- +SELECT a FROM t LIMIT 3 -- normalized! +SELECT (a) FROM t LIMIT (3) -- fully parenthetized +SELECT a FROM t LIMIT _ -- literals removed +SELECT _ FROM _ LIMIT 3 -- identifiers removed + +parse +SELECT a FROM t FETCH NEXT 3 ROWS ONLY +---- +SELECT a FROM t LIMIT 3 -- normalized! +SELECT (a) FROM t LIMIT (3) -- fully parenthetized +SELECT a FROM t LIMIT _ -- literals removed +SELECT _ FROM _ LIMIT 3 -- identifiers removed + +parse +SELECT a FROM t FETCH FIRST ROW ONLY +---- +SELECT a FROM t LIMIT 1 -- normalized! +SELECT (a) FROM t LIMIT (1) -- fully parenthetized +SELECT a FROM t LIMIT _ -- literals removed +SELECT _ FROM _ LIMIT 1 -- identifiers removed + +parse +SELECT a FROM t FETCH FIRST (2 * a) ROWS ONLY +---- +SELECT a FROM t LIMIT (2 * a) -- normalized! +SELECT (a) FROM t LIMIT ((((2) * (a)))) -- fully parenthetized +SELECT a FROM t LIMIT (_ * a) -- literals removed +SELECT _ FROM _ LIMIT (2 * _) -- identifiers removed + +parse +SELECT a FROM t OFFSET b FETCH FIRST (2 * a) ROWS ONLY +---- +SELECT a FROM t LIMIT (2 * a) OFFSET b -- normalized! +SELECT (a) FROM t LIMIT ((((2) * (a)))) OFFSET (b) -- fully parenthetized +SELECT a FROM t LIMIT (_ * a) OFFSET b -- literals removed +SELECT _ FROM _ LIMIT (2 * _) OFFSET _ -- identifiers removed + +parse +SELECT a FROM t FETCH FIRST (2 * a) ROWS ONLY OFFSET b ROWS +---- +SELECT a FROM t LIMIT (2 * a) OFFSET b -- normalized! +SELECT (a) FROM t LIMIT ((((2) * (a)))) OFFSET (b) -- fully parenthetized +SELECT a FROM t LIMIT (_ * a) OFFSET b -- literals removed +SELECT _ FROM _ LIMIT (2 * _) OFFSET _ -- identifiers removed + +parse +SELECT a FROM t FETCH FIRST $1 ROWS ONLY OFFSET $2 ROWS +---- +SELECT a FROM t LIMIT $1 OFFSET $2 -- normalized! +SELECT (a) FROM t LIMIT ($1) OFFSET ($2) -- fully parenthetized +SELECT a FROM t LIMIT $1 OFFSET $2 -- literals removed +SELECT _ FROM _ LIMIT $1 OFFSET $2 -- identifiers removed + +parse +SELECT a FROM t FETCH FIRST +3 ROWS ONLY OFFSET +3 ROWS +---- +SELECT a FROM t LIMIT 3 OFFSET 3 -- normalized! +SELECT (a) FROM t LIMIT (3) OFFSET (3) -- fully parenthetized +SELECT a FROM t LIMIT _ OFFSET _ -- literals removed +SELECT _ FROM _ LIMIT 3 OFFSET 3 -- identifiers removed + +parse +SELECT a FROM t FETCH FIRST -3 ROWS ONLY OFFSET -3 ROWS +---- +SELECT a FROM t LIMIT -3 OFFSET -3 -- normalized! +SELECT (a) FROM t LIMIT (-3) OFFSET (-3) -- fully parenthetized +SELECT a FROM t LIMIT _ OFFSET _ -- literals removed +SELECT _ FROM _ LIMIT -3 OFFSET -3 -- identifiers removed + +parse +SELECT a FROM t FETCH FIRST +3.0 ROWS ONLY OFFSET +3.0 ROWS +---- +SELECT a FROM t LIMIT 3.0 OFFSET 3.0 -- normalized! +SELECT (a) FROM t LIMIT (3.0) OFFSET (3.0) -- fully parenthetized +SELECT a FROM t LIMIT _ OFFSET _ -- literals removed +SELECT _ FROM _ LIMIT 3.0 OFFSET 3.0 -- identifiers removed + +parse +SELECT a FROM t FETCH FIRST -3.0 ROWS ONLY OFFSET -3.0 ROWS +---- +SELECT a FROM t LIMIT -3.0 OFFSET -3.0 -- normalized! +SELECT (a) FROM t LIMIT (-3.0) OFFSET (-3.0) -- fully parenthetized +SELECT a FROM t LIMIT _ OFFSET _ -- literals removed +SELECT _ FROM _ LIMIT -3.0 OFFSET -3.0 -- identifiers removed + + + +parse +SELECT DISTINCT * FROM t +---- +SELECT DISTINCT * FROM t +SELECT DISTINCT (*) FROM t -- fully parenthetized +SELECT DISTINCT * FROM t -- literals removed +SELECT DISTINCT * FROM _ -- identifiers removed + +parse +SELECT DISTINCT a, b FROM t +---- +SELECT DISTINCT a, b FROM t +SELECT DISTINCT (a), (b) FROM t -- fully parenthetized +SELECT DISTINCT a, b FROM t -- literals removed +SELECT DISTINCT _, _ FROM _ -- identifiers removed + +parse +SELECT DISTINCT ON (a, b) c FROM t +---- +SELECT DISTINCT ON (a, b) c FROM t +SELECT DISTINCT ON ((a), (b)) (c) FROM t -- fully parenthetized +SELECT DISTINCT ON (a, b) c FROM t -- literals removed +SELECT DISTINCT ON (_, _) _ FROM _ -- identifiers removed + +parse +SELECT * FROM (VALUES (1, 2)) AS foo +---- +SELECT * FROM (VALUES (1, 2)) AS foo +SELECT (*) FROM ((VALUES ((1), (2)))) AS foo -- fully parenthetized +SELECT * FROM (VALUES (_, _)) AS foo -- literals removed +SELECT * FROM (VALUES (1, 2)) AS _ -- identifiers removed + +parse +SELECT * FROM (VALUES (1, 2)) AS foo (a, b) +---- +SELECT * FROM (VALUES (1, 2)) AS foo (a, b) +SELECT (*) FROM ((VALUES ((1), (2)))) AS foo (a, b) -- fully parenthetized +SELECT * FROM (VALUES (_, _)) AS foo (a, b) -- literals removed +SELECT * FROM (VALUES (1, 2)) AS _ (_, _) -- identifiers removed + +parse +SELECT 'a' FROM t@{FORCE_INDEX=bar} +---- +SELECT 'a' FROM t@bar -- normalized! +SELECT ('a') FROM t@bar -- fully parenthetized +SELECT _ FROM t@bar -- literals removed +SELECT 'a' FROM _@_ -- identifiers removed + +parse +SELECT 'a' FROM t@{ASC,FORCE_INDEX=idx} +---- +SELECT 'a' FROM t@{FORCE_INDEX=idx,ASC} -- normalized! +SELECT ('a') FROM t@{FORCE_INDEX=idx,ASC} -- fully parenthetized +SELECT _ FROM t@{FORCE_INDEX=idx,ASC} -- literals removed +SELECT 'a' FROM _@{FORCE_INDEX=_,ASC} -- identifiers removed + + +parse +SELECT 1 FOR UPDATE +---- +SELECT 1 FOR UPDATE +SELECT (1) FOR UPDATE -- fully parenthetized +SELECT _ FOR UPDATE -- literals removed +SELECT 1 FOR UPDATE -- identifiers removed + +parse +SELECT 1 FOR NO KEY UPDATE +---- +SELECT 1 FOR NO KEY UPDATE +SELECT (1) FOR NO KEY UPDATE -- fully parenthetized +SELECT _ FOR NO KEY UPDATE -- literals removed +SELECT 1 FOR NO KEY UPDATE -- identifiers removed + +parse +SELECT 1 FOR SHARE +---- +SELECT 1 FOR SHARE +SELECT (1) FOR SHARE -- fully parenthetized +SELECT _ FOR SHARE -- literals removed +SELECT 1 FOR SHARE -- identifiers removed + +parse +SELECT 1 FOR KEY SHARE +---- +SELECT 1 FOR KEY SHARE +SELECT (1) FOR KEY SHARE -- fully parenthetized +SELECT _ FOR KEY SHARE -- literals removed +SELECT 1 FOR KEY SHARE -- identifiers removed + +parse +SELECT 1 FOR UPDATE OF a +---- +SELECT 1 FOR UPDATE OF a +SELECT (1) FOR UPDATE OF a -- fully parenthetized +SELECT _ FOR UPDATE OF a -- literals removed +SELECT 1 FOR UPDATE OF _ -- identifiers removed + +parse +SELECT 1 FOR NO KEY UPDATE OF a, b +---- +SELECT 1 FOR NO KEY UPDATE OF a, b +SELECT (1) FOR NO KEY UPDATE OF a, b -- fully parenthetized +SELECT _ FOR NO KEY UPDATE OF a, b -- literals removed +SELECT 1 FOR NO KEY UPDATE OF _, _ -- identifiers removed + +parse +SELECT 1 FOR UPDATE SKIP LOCKED +---- +SELECT 1 FOR UPDATE SKIP LOCKED +SELECT (1) FOR UPDATE SKIP LOCKED -- fully parenthetized +SELECT _ FOR UPDATE SKIP LOCKED -- literals removed +SELECT 1 FOR UPDATE SKIP LOCKED -- identifiers removed + +parse +SELECT 1 FOR NO KEY UPDATE OF a, b NOWAIT +---- +SELECT 1 FOR NO KEY UPDATE OF a, b NOWAIT +SELECT (1) FOR NO KEY UPDATE OF a, b NOWAIT -- fully parenthetized +SELECT _ FOR NO KEY UPDATE OF a, b NOWAIT -- literals removed +SELECT 1 FOR NO KEY UPDATE OF _, _ NOWAIT -- identifiers removed + +parse +SELECT 1 ORDER BY 1 FOR UPDATE +---- +SELECT 1 ORDER BY 1 FOR UPDATE +SELECT (1) ORDER BY (1) FOR UPDATE -- fully parenthetized +SELECT _ ORDER BY _ FOR UPDATE -- literals removed +SELECT 1 ORDER BY 1 FOR UPDATE -- identifiers removed + +parse +SELECT 1 LIMIT 1 FOR UPDATE +---- +SELECT 1 LIMIT 1 FOR UPDATE +SELECT (1) LIMIT (1) FOR UPDATE -- fully parenthetized +SELECT _ LIMIT _ FOR UPDATE -- literals removed +SELECT 1 LIMIT 1 FOR UPDATE -- identifiers removed + +parse +SELECT 1 ORDER BY 1 LIMIT 1 FOR UPDATE +---- +SELECT 1 ORDER BY 1 LIMIT 1 FOR UPDATE +SELECT (1) ORDER BY (1) LIMIT (1) FOR UPDATE -- fully parenthetized +SELECT _ ORDER BY _ LIMIT _ FOR UPDATE -- literals removed +SELECT 1 ORDER BY 1 LIMIT 1 FOR UPDATE -- identifiers removed + +parse +SELECT 1 ORDER BY 1 FOR UPDATE LIMIT 1 +---- +SELECT 1 ORDER BY 1 LIMIT 1 FOR UPDATE -- normalized! +SELECT (1) ORDER BY (1) LIMIT (1) FOR UPDATE -- fully parenthetized +SELECT _ ORDER BY _ LIMIT _ FOR UPDATE -- literals removed +SELECT 1 ORDER BY 1 LIMIT 1 FOR UPDATE -- identifiers removed + +parse +SELECT 1 FOR READ ONLY +---- +SELECT 1 -- normalized! +SELECT (1) -- fully parenthetized +SELECT _ -- literals removed +SELECT 1 -- identifiers removed + +parse +SELECT 1 FOR UPDATE FOR UPDATE +---- +SELECT 1 FOR UPDATE FOR UPDATE +SELECT (1) FOR UPDATE FOR UPDATE -- fully parenthetized +SELECT _ FOR UPDATE FOR UPDATE -- literals removed +SELECT 1 FOR UPDATE FOR UPDATE -- identifiers removed + +parse +SELECT 1 FOR SHARE OF a FOR KEY SHARE SKIP LOCKED +---- +SELECT 1 FOR SHARE OF a FOR KEY SHARE SKIP LOCKED +SELECT (1) FOR SHARE OF a FOR KEY SHARE SKIP LOCKED -- fully parenthetized +SELECT _ FOR SHARE OF a FOR KEY SHARE SKIP LOCKED -- literals removed +SELECT 1 FOR SHARE OF _ FOR KEY SHARE SKIP LOCKED -- identifiers removed + + +# regression test: the last "0" once mistakenly lost its quotes + +parse +SELECT * FROM "0" JOIN "0" USING (id, "0") +---- +SELECT * FROM "0" JOIN "0" USING (id, "0") +SELECT (*) FROM "0" JOIN "0" USING (id, "0") -- fully parenthetized +SELECT * FROM "0" JOIN "0" USING (id, "0") -- literals removed +SELECT * FROM _ JOIN _ USING (_, _) -- identifiers removed + +# Regression test for #15926 + +parse +SELECT * FROM ((t1 NATURAL JOIN t2 WITH ORDINALITY AS o1)) WITH ORDINALITY AS o2 +---- +SELECT * FROM ((t1 NATURAL JOIN t2 WITH ORDINALITY AS o1)) WITH ORDINALITY AS o2 +SELECT (*) FROM ((t1 NATURAL JOIN t2 WITH ORDINALITY AS o1)) WITH ORDINALITY AS o2 -- fully parenthetized +SELECT * FROM ((t1 NATURAL JOIN t2 WITH ORDINALITY AS o1)) WITH ORDINALITY AS o2 -- literals removed +SELECT * FROM ((_ NATURAL JOIN _ WITH ORDINALITY AS _)) WITH ORDINALITY AS _ -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/select_exprs b/pkg/sql/parser/testdata/parse/select_exprs new file mode 100644 index 000000000000..7aa6448bbed8 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/select_exprs @@ -0,0 +1,1617 @@ +parse +SELECT 1 + 1 +---- +SELECT 1 + 1 +SELECT ((1) + (1)) -- fully parenthetized +SELECT _ + _ -- literals removed +SELECT 1 + 1 -- identifiers removed + +parse +SELECT +1 +---- +SELECT 1 -- normalized! +SELECT (1) -- fully parenthetized +SELECT _ -- literals removed +SELECT 1 -- identifiers removed + +parse +SELECT - - 5 +---- +SELECT 5 -- normalized! +SELECT (5) -- fully parenthetized +SELECT _ -- literals removed +SELECT 5 -- identifiers removed + +parse +SELECT - + 5 +---- +SELECT -5 -- normalized! +SELECT (-5) -- fully parenthetized +SELECT _ -- literals removed +SELECT -5 -- identifiers removed + +parse +SELECT -1 +---- +SELECT -1 +SELECT (-1) -- fully parenthetized +SELECT _ -- literals removed +SELECT -1 -- identifiers removed + +parse +SELECT .1 +---- +SELECT .1 +SELECT (.1) -- fully parenthetized +SELECT _ -- literals removed +SELECT .1 -- identifiers removed + +parse +SELECT 1.2e1 +---- +SELECT 1.2e1 +SELECT (1.2e1) -- fully parenthetized +SELECT _ -- literals removed +SELECT 1.2e1 -- identifiers removed + +parse +SELECT 1.2e+1 +---- +SELECT 1.2e+1 +SELECT (1.2e+1) -- fully parenthetized +SELECT _ -- literals removed +SELECT 1.2e+1 -- identifiers removed + +parse +SELECT 1.2e-1 +---- +SELECT 1.2e-1 +SELECT (1.2e-1) -- fully parenthetized +SELECT _ -- literals removed +SELECT 1.2e-1 -- identifiers removed + +parse +SELECT *,-/* comment */-5 +---- +SELECT *, 5 -- normalized! +SELECT (*), (5) -- fully parenthetized +SELECT *, _ -- literals removed +SELECT *, 5 -- identifiers removed + +parse +SELECT - +-5 +---- +SELECT 5 -- normalized! +SELECT (5) -- fully parenthetized +SELECT _ -- literals removed +SELECT 5 -- identifiers removed + +parse +SELECT -0.-/*test*/-1 +---- +SELECT -0. - -1 -- normalized! +SELECT ((-0.) - (-1)) -- fully parenthetized +SELECT _ - _ -- literals removed +SELECT -0. - -1 -- identifiers removed + +parse +SELECT~~+~++~bd(*) +---- +SELECT ~(~(~(~bd(*)))) -- normalized! +SELECT (~((~((~((~((bd)((*)))))))))) -- fully parenthetized +SELECT ~(~(~(~bd(*)))) -- literals removed +SELECT ~(~(~(~bd(*)))) -- identifiers removed + +parse +SELECT true AND false +---- +SELECT true AND false +SELECT ((true) AND (false)) -- fully parenthetized +SELECT _ AND _ -- literals removed +SELECT true AND false -- identifiers removed + +parse +SELECT true AND NULL +---- +SELECT true AND NULL +SELECT ((true) AND (NULL)) -- fully parenthetized +SELECT _ AND _ -- literals removed +SELECT true AND NULL -- identifiers removed + +parse +SELECT true = false +---- +SELECT true = false +SELECT ((true) = (false)) -- fully parenthetized +SELECT _ = _ -- literals removed +SELECT true = false -- identifiers removed + +parse +SELECT (true = false) +---- +SELECT (true = false) +SELECT ((((true) = (false)))) -- fully parenthetized +SELECT (_ = _) -- literals removed +SELECT (true = false) -- identifiers removed + +parse +SELECT (ARRAY['a', 'b'])[2] +---- +SELECT (ARRAY['a', 'b'])[2] +SELECT ((((ARRAY[('a'), ('b')])))[(2)]) -- fully parenthetized +SELECT (ARRAY[_, _])[_] -- literals removed +SELECT (ARRAY['a', 'b'])[2] -- identifiers removed + +parse +SELECT (ARRAY (VALUES (1), (2)))[1] +---- +SELECT (ARRAY (VALUES (1), (2)))[1] +SELECT ((((ARRAY ((VALUES ((1)), ((2)))))))[(1)]) -- fully parenthetized +SELECT (ARRAY (VALUES (_), (__more1__)))[_] -- literals removed +SELECT (ARRAY (VALUES (1), (2)))[1] -- identifiers removed + +parse +SELECT+y[array[]] +---- +SELECT y[ARRAY[]] -- normalized! +SELECT ((y)[(ARRAY[])]) -- fully parenthetized +SELECT y[ARRAY[]] -- literals removed +SELECT _[ARRAY[]] -- identifiers removed + +parse +SELECT (ARRAY (1, 2))[1] +---- +SELECT (ARRAY[1, 2])[1] -- normalized! +SELECT ((((ARRAY[(1), (2)])))[(1)]) -- fully parenthetized +SELECT (ARRAY[_, _])[_] -- literals removed +SELECT (ARRAY[1, 2])[1] -- identifiers removed + +parse +SELECT FAMILY (x) +---- +SELECT "family"(x) -- normalized! +SELECT (("family")((x))) -- fully parenthetized +SELECT "family"(x) -- literals removed +SELECT "family"(_) -- identifiers removed + +parse +SELECT 1 IN (b) +---- +SELECT 1 IN (b,) -- normalized! +SELECT ((1) IN (((b),))) -- fully parenthetized +SELECT _ IN (b,) -- literals removed +SELECT 1 IN (_,) -- identifiers removed + +parse +SELECT ROW() +---- +SELECT () -- normalized! +SELECT (()) -- fully parenthetized +SELECT () -- literals removed +SELECT () -- identifiers removed + +parse +SELECT ROW(1) +---- +SELECT (1,) -- normalized! +SELECT (((1),)) -- fully parenthetized +SELECT (_,) -- literals removed +SELECT (1,) -- identifiers removed + +parse +SELECT (ROW(1) AS a) +---- +SELECT ((1,) AS a) -- normalized! +SELECT ((((1),) AS a)) -- fully parenthetized +SELECT ((_,) AS a) -- literals removed +SELECT ((1,) AS _) -- identifiers removed + +parse +SELECT (SELECT 1) +---- +SELECT (SELECT 1) +SELECT ((SELECT (1))) -- fully parenthetized +SELECT (SELECT _) -- literals removed +SELECT (SELECT 1) -- identifiers removed + +parse +SELECT ((SELECT 1)) +---- +SELECT ((SELECT 1)) +SELECT (((SELECT (1)))) -- fully parenthetized +SELECT ((SELECT _)) -- literals removed +SELECT ((SELECT 1)) -- identifiers removed + +parse +SELECT (SELECT ARRAY['a', 'b'])[2] +---- +SELECT (SELECT ARRAY['a', 'b'])[2] +SELECT (((SELECT (ARRAY[('a'), ('b')])))[(2)]) -- fully parenthetized +SELECT (SELECT ARRAY[_, _])[_] -- literals removed +SELECT (SELECT ARRAY['a', 'b'])[2] -- identifiers removed + +parse +SELECT ((SELECT ARRAY['a', 'b']))[2] +---- +SELECT ((SELECT ARRAY['a', 'b']))[2] +SELECT ((((SELECT (ARRAY[('a'), ('b')]))))[(2)]) -- fully parenthetized +SELECT ((SELECT ARRAY[_, _]))[_] -- literals removed +SELECT ((SELECT ARRAY['a', 'b']))[2] -- identifiers removed + +parse +SELECT ((((VALUES (1))))) +---- +SELECT ((((VALUES (1))))) +SELECT (((((VALUES ((1))))))) -- fully parenthetized +SELECT ((((VALUES (_))))) -- literals removed +SELECT ((((VALUES (1))))) -- identifiers removed + +parse +SELECT EXISTS (SELECT 1) +---- +SELECT EXISTS (SELECT 1) +SELECT (EXISTS (SELECT (1))) -- fully parenthetized +SELECT EXISTS (SELECT _) -- literals removed +SELECT EXISTS (SELECT 1) -- identifiers removed + +parse +SELECT (VALUES (1)) +---- +SELECT (VALUES (1)) +SELECT ((VALUES ((1)))) -- fully parenthetized +SELECT (VALUES (_)) -- literals removed +SELECT (VALUES (1)) -- identifiers removed + +parse +SELECT (1, 2, 3) +---- +SELECT (1, 2, 3) +SELECT (((1), (2), (3))) -- fully parenthetized +SELECT (_, _, __more1__) -- literals removed +SELECT (1, 2, 3) -- identifiers removed + +parse +SELECT ((1, 2, 3) AS a, b, c) +---- +SELECT ((1, 2, 3) AS a, b, c) +SELECT ((((1), (2), (3)) AS a, b, c)) -- fully parenthetized +SELECT ((_, _, __more1__) AS a, b) -- literals removed +SELECT ((1, 2, 3) AS _, _, _) -- identifiers removed + +parse +SELECT ((1, 2, 3)) +---- +SELECT ((1, 2, 3)) +SELECT (((((1), (2), (3))))) -- fully parenthetized +SELECT ((_, _, __more1__)) -- literals removed +SELECT ((1, 2, 3)) -- identifiers removed + +parse +SELECT ((1, 2, 3) AS a, b, c) +---- +SELECT ((1, 2, 3) AS a, b, c) +SELECT ((((1), (2), (3)) AS a, b, c)) -- fully parenthetized +SELECT ((_, _, __more1__) AS a, b) -- literals removed +SELECT ((1, 2, 3) AS _, _, _) -- identifiers removed + +parse +SELECT (((1, 2, 3) AS a, b, c)).a +---- +SELECT (((1, 2, 3) AS a, b, c)).a +SELECT ((((((1), (2), (3)) AS a, b, c))).a) -- fully parenthetized +SELECT (((_, _, __more1__) AS a, b)).a -- literals removed +SELECT (((1, 2, 3) AS _, _, _))._ -- identifiers removed + +parse +SELECT (((1, 2, 3) AS a, b, c)).* +---- +SELECT (((1, 2, 3) AS a, b, c)).* +SELECT ((((((1), (2), (3)) AS a, b, c))).*) -- fully parenthetized +SELECT (((_, _, __more1__) AS a, b)).* -- literals removed +SELECT (((1, 2, 3) AS _, _, _)).* -- identifiers removed + +parse +SELECT () +---- +SELECT () +SELECT (()) -- fully parenthetized +SELECT () -- literals removed +SELECT () -- identifiers removed + +parse +SELECT (() AS a) +---- +SELECT (() AS a) +SELECT ((() AS a)) -- fully parenthetized +SELECT (() AS a) -- literals removed +SELECT (() AS _) -- identifiers removed + +parse +SELECT ((() AS a)).a +---- +SELECT ((() AS a)).a +SELECT ((((() AS a))).a) -- fully parenthetized +SELECT ((() AS a)).a -- literals removed +SELECT ((() AS _))._ -- identifiers removed + +parse +SELECT ((() AS a)).* +---- +SELECT ((() AS a)).* +SELECT ((((() AS a))).*) -- fully parenthetized +SELECT ((() AS a)).* -- literals removed +SELECT ((() AS _)).* -- identifiers removed + +parse +SELECT ((() AS a)).@1 +---- +SELECT ((() AS a)).@1 +SELECT ((((() AS a))).@1) -- fully parenthetized +SELECT ((() AS a)).@1 -- literals removed +SELECT ((() AS _)).@1 -- identifiers removed + +parse +SELECT (TABLE a) +---- +SELECT (TABLE a) +SELECT ((TABLE a)) -- fully parenthetized +SELECT (TABLE a) -- literals removed +SELECT (TABLE _) -- identifiers removed + +parse +SELECT 0x1 +---- +SELECT 0x1 +SELECT (0x1) -- fully parenthetized +SELECT _ -- literals removed +SELECT 0x1 -- identifiers removed + +parse +SELECT 'a''a' +---- +SELECT e'a\'a' -- normalized! +SELECT (e'a\'a') -- fully parenthetized +SELECT _ -- literals removed +SELECT e'a\'a' -- identifiers removed + +parse +SELECT 'a\a' +---- +SELECT e'a\\a' -- normalized! +SELECT (e'a\\a') -- fully parenthetized +SELECT _ -- literals removed +SELECT e'a\\a' -- identifiers removed + +parse +SELECT 'a\n' +---- +SELECT e'a\\n' -- normalized! +SELECT (e'a\\n') -- fully parenthetized +SELECT _ -- literals removed +SELECT e'a\\n' -- identifiers removed + +parse +SELECT ' +' +---- +SELECT e'\n' -- normalized! +SELECT (e'\n') -- fully parenthetized +SELECT _ -- literals removed +SELECT e'\n' -- identifiers removed + +parse +SELECT ' +\' +---- +SELECT e'\n\\' -- normalized! +SELECT (e'\n\\') -- fully parenthetized +SELECT _ -- literals removed +SELECT e'\n\\' -- identifiers removed + +parse +SELECT x'61' +---- +SELECT b'a' -- normalized! +SELECT (b'a') -- fully parenthetized +SELECT _ -- literals removed +SELECT b'a' -- identifiers removed + +parse +SELECT X'61' +---- +SELECT b'a' -- normalized! +SELECT (b'a') -- fully parenthetized +SELECT _ -- literals removed +SELECT b'a' -- identifiers removed + + +parse +SELECT 'Deutsch' COLLATE de +---- +SELECT 'Deutsch' COLLATE de +SELECT (('Deutsch') COLLATE de) -- fully parenthetized +SELECT _ COLLATE de -- literals removed +SELECT 'Deutsch' COLLATE de -- identifiers removed + +parse +SELECT a @> b +---- +SELECT a @> b +SELECT ((a) @> (b)) -- fully parenthetized +SELECT a @> b -- literals removed +SELECT _ @> _ -- identifiers removed + +parse +SELECT a <@ b +---- +SELECT a <@ b +SELECT ((a) <@ (b)) -- fully parenthetized +SELECT a <@ b -- literals removed +SELECT _ <@ _ -- identifiers removed + +parse +SELECT a ? b +---- +SELECT a ? b +SELECT ((a) ? (b)) -- fully parenthetized +SELECT a ? b -- literals removed +SELECT _ ? _ -- identifiers removed + +parse +SELECT a ?| b +---- +SELECT a ?| b +SELECT ((a) ?| (b)) -- fully parenthetized +SELECT a ?| b -- literals removed +SELECT _ ?| _ -- identifiers removed + +parse +SELECT a ?& b +---- +SELECT a ?& b +SELECT ((a) ?& (b)) -- fully parenthetized +SELECT a ?& b -- literals removed +SELECT _ ?& _ -- identifiers removed + +## The following JSON expressions +## do not anonymize properly, see +## issue https://github.com/cockroachdb/cockroach/issues/60673 + +parse +SELECT a->'x' +---- +SELECT a->'x' +SELECT ((a)->('x')) -- fully parenthetized +SELECT a->_ -- literals removed +SELECT _->'x' -- identifiers removed + +parse +SELECT a#>'{x}' +---- +SELECT a#>'{x}' +SELECT ((a)#>('{x}')) -- fully parenthetized +SELECT a#>_ -- literals removed +SELECT _#>'{x}' -- identifiers removed + +parse +SELECT a#>>'{x}' +---- +SELECT a#>>'{x}' +SELECT ((a)#>>('{x}')) -- fully parenthetized +SELECT a#>>_ -- literals removed +SELECT _#>>'{x}' -- identifiers removed + +parse +SELECT (a->'x')->'y' +---- +SELECT (a->'x')->'y' +SELECT (((((a)->('x'))))->('y')) -- fully parenthetized +SELECT (a->_)->_ -- literals removed +SELECT (_->'x')->'y' -- identifiers removed + +parse +SELECT (a->'x')->>'y' +---- +SELECT (a->'x')->>'y' +SELECT (((((a)->('x'))))->>('y')) -- fully parenthetized +SELECT (a->_)->>_ -- literals removed +SELECT (_->'x')->>'y' -- identifiers removed + +parse +SELECT a #- '{x}' +---- +SELECT json_remove_path(a, '{x}') -- normalized! +SELECT (json_remove_path((a), ('{x}'))) -- fully parenthetized +SELECT json_remove_path(a, _) -- literals removed +SELECT json_remove_path(_, '{x}') -- identifiers removed + + +parse +SELECT b && c +---- +SELECT b && c +SELECT ((b) && (c)) -- fully parenthetized +SELECT b && c -- literals removed +SELECT _ && _ -- identifiers removed + +parse +SELECT |/a +---- +SELECT |/a +SELECT (|/(a)) -- fully parenthetized +SELECT |/a -- literals removed +SELECT |/_ -- identifiers removed + +parse +SELECT ||/a +---- +SELECT ||/a +SELECT (||/(a)) -- fully parenthetized +SELECT ||/a -- literals removed +SELECT ||/_ -- identifiers removed + + +parse +SELECT BOOL 'foo', 'foo'::BOOL +---- +SELECT BOOL 'foo', 'foo'::BOOL +SELECT (BOOL ('foo')), (('foo')::BOOL) -- fully parenthetized +SELECT BOOL _, _::BOOL -- literals removed +SELECT bool AS _, _::BOOL -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT BOOL 'foo', 'foo'::BOOL -- identifiers removed + +parse +SELECT BIT '10', '10'::BIT +---- +SELECT BIT '10', '10'::BIT +SELECT (BIT ('10')), (('10')::BIT) -- fully parenthetized +SELECT BIT _, _::BIT -- literals removed +SELECT "bit" AS _, _::BIT -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT BIT '10', '10'::BIT -- identifiers removed + +parse +SELECT VARBIT '1', '1'::VARBIT +---- +SELECT VARBIT '1', '1'::VARBIT +SELECT (VARBIT ('1')), (('1')::VARBIT) -- fully parenthetized +SELECT VARBIT _, _::VARBIT -- literals removed +SELECT "varbit" AS _, _::VARBIT -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT VARBIT '1', '1'::VARBIT -- identifiers removed + +parse +SELECT INT2 'foo', 'foo'::INT2 +---- +SELECT INT2 'foo', 'foo'::INT2 +SELECT (INT2 ('foo')), (('foo')::INT2) -- fully parenthetized +SELECT INT2 _, _::INT2 -- literals removed +SELECT int2 AS _, _::INT2 -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT INT2 'foo', 'foo'::INT2 -- identifiers removed + +parse +SELECT INT4 'foo', 'foo'::INT4 +---- +SELECT INT4 'foo', 'foo'::INT4 +SELECT (INT4 ('foo')), (('foo')::INT4) -- fully parenthetized +SELECT INT4 _, _::INT4 -- literals removed +SELECT int4 AS _, _::INT4 -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT INT4 'foo', 'foo'::INT4 -- identifiers removed + +parse +SELECT INT8 'foo', 'foo'::INT8 +---- +SELECT INT8 'foo', 'foo'::INT8 +SELECT (INT8 ('foo')), (('foo')::INT8) -- fully parenthetized +SELECT INT8 _, _::INT8 -- literals removed +SELECT int8 AS _, _::INT8 -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT INT8 'foo', 'foo'::INT8 -- identifiers removed + +parse +SELECT FLOAT4 'foo', 'foo'::FLOAT4 +---- +SELECT FLOAT4 'foo', 'foo'::FLOAT4 +SELECT (FLOAT4 ('foo')), (('foo')::FLOAT4) -- fully parenthetized +SELECT FLOAT4 _, _::FLOAT4 -- literals removed +SELECT float4 AS _, _::FLOAT4 -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT FLOAT4 'foo', 'foo'::FLOAT4 -- identifiers removed + +parse +SELECT REAL 'foo' +---- +SELECT FLOAT4 'foo' -- normalized! +SELECT (FLOAT4 ('foo')) -- fully parenthetized +SELECT FLOAT4 _ -- literals removed +SELECT float4 AS _ -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT FLOAT4 'foo' -- identifiers removed + +parse +SELECT DOUBLE PRECISION 'foo' +---- +SELECT FLOAT8 'foo' -- normalized! +SELECT (FLOAT8 ('foo')) -- fully parenthetized +SELECT FLOAT8 _ -- literals removed +SELECT float8 AS _ -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT FLOAT8 'foo' -- identifiers removed + + +parse +SELECT DECIMAL 'foo', 'foo'::DECIMAL +---- +SELECT DECIMAL 'foo', 'foo'::DECIMAL +SELECT (DECIMAL ('foo')), (('foo')::DECIMAL) -- fully parenthetized +SELECT DECIMAL _, _::DECIMAL -- literals removed +SELECT "decimal" AS _, _::DECIMAL -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT DECIMAL 'foo', 'foo'::DECIMAL -- identifiers removed + +parse +SELECT NUMERIC 'foo' +---- +SELECT DECIMAL 'foo' -- normalized! +SELECT (DECIMAL ('foo')) -- fully parenthetized +SELECT DECIMAL _ -- literals removed +SELECT "decimal" AS _ -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT DECIMAL 'foo' -- identifiers removed + + +parse +SELECT CHAR 'foo', 'foo'::CHAR +---- +SELECT CHAR 'foo', 'foo'::CHAR +SELECT (CHAR ('foo')), (('foo')::CHAR) -- fully parenthetized +SELECT CHAR _, _::CHAR -- literals removed +SELECT "char" AS _, _::CHAR -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT CHAR 'foo', 'foo'::CHAR -- identifiers removed + +parse +SELECT VARCHAR 'foo', 'foo'::VARCHAR +---- +SELECT VARCHAR 'foo', 'foo'::VARCHAR +SELECT (VARCHAR ('foo')), (('foo')::VARCHAR) -- fully parenthetized +SELECT VARCHAR _, _::VARCHAR -- literals removed +SELECT "varchar" AS _, _::VARCHAR -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT VARCHAR 'foo', 'foo'::VARCHAR -- identifiers removed + +parse +SELECT STRING 'foo', 'foo'::STRING +---- +SELECT STRING 'foo', 'foo'::STRING +SELECT (STRING ('foo')), (('foo')::STRING) -- fully parenthetized +SELECT STRING _, _::STRING -- literals removed +SELECT "string" AS _, _::STRING -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT STRING 'foo', 'foo'::STRING -- identifiers removed + +parse +SELECT BYTES 'foo', 'foo'::BYTES +---- +SELECT BYTES 'foo', 'foo'::BYTES +SELECT (BYTES ('foo')), (('foo')::BYTES) -- fully parenthetized +SELECT BYTES _, _::BYTES -- literals removed +SELECT bytes AS _, _::BYTES -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT BYTES 'foo', 'foo'::BYTES -- identifiers removed + +parse +SELECT DATE 'foo', 'foo'::DATE +---- +SELECT DATE 'foo', 'foo'::DATE +SELECT (DATE ('foo')), (('foo')::DATE) -- fully parenthetized +SELECT DATE _, _::DATE -- literals removed +SELECT date AS _, _::DATE -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT DATE 'foo', 'foo'::DATE -- identifiers removed + +parse +SELECT TIME 'foo', 'foo'::TIME +---- +SELECT TIME 'foo', 'foo'::TIME +SELECT (TIME ('foo')), (('foo')::TIME) -- fully parenthetized +SELECT TIME _, _::TIME -- literals removed +SELECT "time" AS _, _::TIME -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT TIME 'foo', 'foo'::TIME -- identifiers removed + +parse +SELECT TIMESTAMP 'foo', 'foo'::TIMESTAMP +---- +SELECT TIMESTAMP 'foo', 'foo'::TIMESTAMP +SELECT (TIMESTAMP ('foo')), (('foo')::TIMESTAMP) -- fully parenthetized +SELECT TIMESTAMP _, _::TIMESTAMP -- literals removed +SELECT "timestamp" AS _, _::TIMESTAMP -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT TIMESTAMP 'foo', 'foo'::TIMESTAMP -- identifiers removed + +parse +SELECT TIMESTAMPTZ 'foo', 'foo'::TIMESTAMPTZ +---- +SELECT TIMESTAMPTZ 'foo', 'foo'::TIMESTAMPTZ +SELECT (TIMESTAMPTZ ('foo')), (('foo')::TIMESTAMPTZ) -- fully parenthetized +SELECT TIMESTAMPTZ _, _::TIMESTAMPTZ -- literals removed +SELECT "timestamptz" AS _, _::TIMESTAMPTZ -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT TIMESTAMPTZ 'foo', 'foo'::TIMESTAMPTZ -- identifiers removed + +parse +SELECT TIMESTAMP WITHOUT TIME ZONE 'foo' +---- +SELECT TIMESTAMP 'foo' -- normalized! +SELECT (TIMESTAMP ('foo')) -- fully parenthetized +SELECT TIMESTAMP _ -- literals removed +SELECT "timestamp" AS _ -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT TIMESTAMP 'foo' -- identifiers removed + +parse +SELECT 'a'::TIMESTAMP(3) +---- +SELECT 'a'::TIMESTAMP(3) +SELECT (('a')::TIMESTAMP(3)) -- fully parenthetized +SELECT _::TIMESTAMP(3) -- literals removed +SELECT 'a'::TIMESTAMP(3) -- identifiers removed + +parse +SELECT 'a'::TIMESTAMP(3) WITHOUT TIME ZONE +---- +SELECT 'a'::TIMESTAMP(3) -- normalized! +SELECT (('a')::TIMESTAMP(3)) -- fully parenthetized +SELECT _::TIMESTAMP(3) -- literals removed +SELECT 'a'::TIMESTAMP(3) -- identifiers removed + +parse +SELECT 'a'::TIMESTAMPTZ(3) +---- +SELECT 'a'::TIMESTAMPTZ(3) +SELECT (('a')::TIMESTAMPTZ(3)) -- fully parenthetized +SELECT _::TIMESTAMPTZ(3) -- literals removed +SELECT 'a'::TIMESTAMPTZ(3) -- identifiers removed + +parse +SELECT 'a'::TIMESTAMP(3) WITH TIME ZONE +---- +SELECT 'a'::TIMESTAMPTZ(3) -- normalized! +SELECT (('a')::TIMESTAMPTZ(3)) -- fully parenthetized +SELECT _::TIMESTAMPTZ(3) -- literals removed +SELECT 'a'::TIMESTAMPTZ(3) -- identifiers removed + +parse +SELECT TIMESTAMP(3) 'a' +---- +SELECT TIMESTAMP(3) 'a' +SELECT (TIMESTAMP(3) ('a')) -- fully parenthetized +SELECT TIMESTAMP(3) _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +SELECT TIMESTAMP(3) 'a' -- identifiers removed + +parse +SELECT TIMESTAMPTZ(3) 'a' +---- +SELECT TIMESTAMPTZ(3) 'a' +SELECT (TIMESTAMPTZ(3) ('a')) -- fully parenthetized +SELECT TIMESTAMPTZ(3) _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +SELECT TIMESTAMPTZ(3) 'a' -- identifiers removed + + +parse +SELECT CAST('foo' AS TIMESTAMP WITHOUT TIME ZONE) +---- +SELECT CAST('foo' AS TIMESTAMP) -- normalized! +SELECT (CAST(('foo') AS TIMESTAMP)) -- fully parenthetized +SELECT CAST(_ AS TIMESTAMP) -- literals removed +SELECT CAST('foo' AS TIMESTAMP) -- identifiers removed + +parse +SELECT CAST(1 AS "timestamp") +---- +SELECT CAST(1 AS TIMESTAMP) -- normalized! +SELECT (CAST((1) AS TIMESTAMP)) -- fully parenthetized +SELECT CAST(_ AS TIMESTAMP) -- literals removed +SELECT CAST(1 AS TIMESTAMP) -- identifiers removed + +parse +SELECT JSONB 'foo', 'foo'::JSONB +---- +SELECT JSONB 'foo', 'foo'::JSONB +SELECT (JSONB ('foo')), (('foo')::JSONB) -- fully parenthetized +SELECT JSONB _, _::JSONB -- literals removed +SELECT jsonb AS _, _::JSONB -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT JSONB 'foo', 'foo'::JSONB -- identifiers removed + +parse +SELECT '{}'::JSONB ? 'a' = false +---- +SELECT ('{}'::JSONB ? 'a') = false -- normalized! +SELECT ((((('{}')::JSONB) ? ('a'))) = (false)) -- fully parenthetized +SELECT (_::JSONB ? _) = _ -- literals removed +SELECT ('{}'::JSONB ? 'a') = false -- identifiers removed + +parse +SELECT '{}'::JSONB ?| 'a' = false +---- +SELECT ('{}'::JSONB ?| 'a') = false -- normalized! +SELECT ((((('{}')::JSONB) ?| ('a'))) = (false)) -- fully parenthetized +SELECT (_::JSONB ?| _) = _ -- literals removed +SELECT ('{}'::JSONB ?| 'a') = false -- identifiers removed + +parse +SELECT '{}'::JSONB ?& 'a' = false +---- +SELECT ('{}'::JSONB ?& 'a') = false -- normalized! +SELECT ((((('{}')::JSONB) ?& ('a'))) = (false)) -- fully parenthetized +SELECT (_::JSONB ?& _) = _ -- literals removed +SELECT ('{}'::JSONB ?& 'a') = false -- identifiers removed + +parse +SELECT '{}'::JSONB @> '{}'::JSONB = false +---- +SELECT ('{}'::JSONB @> '{}'::JSONB) = false -- normalized! +SELECT ((((('{}')::JSONB) @> (('{}')::JSONB))) = (false)) -- fully parenthetized +SELECT (_::JSONB @> _::JSONB) = _ -- literals removed +SELECT ('{}'::JSONB @> '{}'::JSONB) = false -- identifiers removed + +parse +SELECT '{}'::JSONB <@ '{}'::JSONB = false +---- +SELECT ('{}'::JSONB <@ '{}'::JSONB) = false -- normalized! +SELECT ((((('{}')::JSONB) <@ (('{}')::JSONB))) = (false)) -- fully parenthetized +SELECT (_::JSONB <@ _::JSONB) = _ -- literals removed +SELECT ('{}'::JSONB <@ '{}'::JSONB) = false -- identifiers removed + + +parse +SELECT 'foo'::DECIMAL(1) +---- +SELECT 'foo'::DECIMAL(1) +SELECT (('foo')::DECIMAL(1)) -- fully parenthetized +SELECT _::DECIMAL(1) -- literals removed +SELECT 'foo'::DECIMAL(1) -- identifiers removed + +parse +SELECT 'foo'::DECIMAL(2,1) +---- +SELECT 'foo'::DECIMAL(2,1) +SELECT (('foo')::DECIMAL(2,1)) -- fully parenthetized +SELECT _::DECIMAL(2,1) -- literals removed +SELECT 'foo'::DECIMAL(2,1) -- identifiers removed + +parse +SELECT 'foo'::BIT(3) +---- +SELECT 'foo'::BIT(3) +SELECT (('foo')::BIT(3)) -- fully parenthetized +SELECT _::BIT(3) -- literals removed +SELECT 'foo'::BIT(3) -- identifiers removed + +parse +SELECT 'foo'::VARBIT(3) +---- +SELECT 'foo'::VARBIT(3) +SELECT (('foo')::VARBIT(3)) -- fully parenthetized +SELECT _::VARBIT(3) -- literals removed +SELECT 'foo'::VARBIT(3) -- identifiers removed + +parse +SELECT 'foo'::CHAR(3) +---- +SELECT 'foo'::CHAR(3) +SELECT (('foo')::CHAR(3)) -- fully parenthetized +SELECT _::CHAR(3) -- literals removed +SELECT 'foo'::CHAR(3) -- identifiers removed + +parse +SELECT 'foo'::VARCHAR(3) +---- +SELECT 'foo'::VARCHAR(3) +SELECT (('foo')::VARCHAR(3)) -- fully parenthetized +SELECT _::VARCHAR(3) -- literals removed +SELECT 'foo'::VARCHAR(3) -- identifiers removed + +parse +SELECT 'foo'::STRING(3) +---- +SELECT 'foo'::STRING(3) +SELECT (('foo')::STRING(3)) -- fully parenthetized +SELECT _::STRING(3) -- literals removed +SELECT 'foo'::STRING(3) -- identifiers removed + +parse +SELECT 'foo'::TIMESTAMP(6) +---- +SELECT 'foo'::TIMESTAMP(6) +SELECT (('foo')::TIMESTAMP(6)) -- fully parenthetized +SELECT _::TIMESTAMP(6) -- literals removed +SELECT 'foo'::TIMESTAMP(6) -- identifiers removed + +parse +SELECT 'foo'::TIMESTAMPTZ(6) +---- +SELECT 'foo'::TIMESTAMPTZ(6) +SELECT (('foo')::TIMESTAMPTZ(6)) -- fully parenthetized +SELECT _::TIMESTAMPTZ(6) -- literals removed +SELECT 'foo'::TIMESTAMPTZ(6) -- identifiers removed + +parse +SELECT 'foo'::TIME(6) +---- +SELECT 'foo'::TIME(6) +SELECT (('foo')::TIME(6)) -- fully parenthetized +SELECT _::TIME(6) -- literals removed +SELECT 'foo'::TIME(6) -- identifiers removed + +parse +SELECT 'a'::TIME(3) +---- +SELECT 'a'::TIME(3) +SELECT (('a')::TIME(3)) -- fully parenthetized +SELECT _::TIME(3) -- literals removed +SELECT 'a'::TIME(3) -- identifiers removed + +parse +SELECT 'a'::TIME(3) WITHOUT TIME ZONE +---- +SELECT 'a'::TIME(3) -- normalized! +SELECT (('a')::TIME(3)) -- fully parenthetized +SELECT _::TIME(3) -- literals removed +SELECT 'a'::TIME(3) -- identifiers removed + +parse +SELECT 'a'::TIMETZ(3) +---- +SELECT 'a'::TIMETZ(3) +SELECT (('a')::TIMETZ(3)) -- fully parenthetized +SELECT _::TIMETZ(3) -- literals removed +SELECT 'a'::TIMETZ(3) -- identifiers removed + +parse +SELECT 'a'::TIME(3) WITH TIME ZONE +---- +SELECT 'a'::TIMETZ(3) -- normalized! +SELECT (('a')::TIMETZ(3)) -- fully parenthetized +SELECT _::TIMETZ(3) -- literals removed +SELECT 'a'::TIMETZ(3) -- identifiers removed + +parse +SELECT TIME(3) 'a' +---- +SELECT TIME(3) 'a' +SELECT (TIME(3) ('a')) -- fully parenthetized +SELECT TIME(3) _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +SELECT TIME(3) 'a' -- identifiers removed + +parse +SELECT TIMETZ(3) 'a' +---- +SELECT TIMETZ(3) 'a' +SELECT (TIMETZ(3) ('a')) -- fully parenthetized +SELECT TIMETZ(3) _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +SELECT TIMETZ(3) 'a' -- identifiers removed + + +parse +SELECT '0'::INTERVAL +---- +SELECT '0'::INTERVAL +SELECT (('0')::INTERVAL) -- fully parenthetized +SELECT _::INTERVAL -- literals removed +SELECT '0'::INTERVAL -- identifiers removed + +parse +SELECT INTERVAL '0' +---- +SELECT '00:00:00' -- normalized! +SELECT ('00:00:00') -- fully parenthetized +SELECT _ -- literals removed +SELECT '00:00:00' -- identifiers removed + +parse +SELECT INTERVAL '1' SECOND +---- +SELECT '00:00:01' -- normalized! +SELECT ('00:00:01') -- fully parenthetized +SELECT _ -- literals removed +SELECT '00:00:01' -- identifiers removed + +parse +SELECT INTERVAL(3) '12.1234s' +---- +SELECT '00:00:12.123' -- normalized! +SELECT ('00:00:12.123') -- fully parenthetized +SELECT _ -- literals removed +SELECT '00:00:12.123' -- identifiers removed + +parse +SELECT INTERVAL '12.1234s' SECOND(3) +---- +SELECT '00:00:12.123' -- normalized! +SELECT ('00:00:12.123') -- fully parenthetized +SELECT _ -- literals removed +SELECT '00:00:12.123' -- identifiers removed + +parse +SELECT INTERVAL '14.7899s' SECOND(3) +---- +SELECT '00:00:14.79' -- normalized! +SELECT ('00:00:14.79') -- fully parenthetized +SELECT _ -- literals removed +SELECT '00:00:14.79' -- identifiers removed + +parse +SELECT '11s'::INTERVAL(3) +---- +SELECT '11s'::INTERVAL(3) +SELECT (('11s')::INTERVAL(3)) -- fully parenthetized +SELECT _::INTERVAL(3) -- literals removed +SELECT '11s'::INTERVAL(3) -- identifiers removed + +parse +SELECT '10:00:13.123456'::INTERVAL SECOND +---- +SELECT '10:00:13.123456'::INTERVAL SECOND +SELECT (('10:00:13.123456')::INTERVAL SECOND) -- fully parenthetized +SELECT _::INTERVAL SECOND -- literals removed +SELECT '10:00:13.123456'::INTERVAL SECOND -- identifiers removed + +parse +SELECT '10:00:13.123456'::INTERVAL SECOND(3) +---- +SELECT '10:00:13.123456'::INTERVAL SECOND(3) +SELECT (('10:00:13.123456')::INTERVAL SECOND(3)) -- fully parenthetized +SELECT _::INTERVAL SECOND(3) -- literals removed +SELECT '10:00:13.123456'::INTERVAL SECOND(3) -- identifiers removed + +parse +SELECT '10:00:13.123456'::INTERVAL MINUTE TO SECOND +---- +SELECT '10:00:13.123456'::INTERVAL MINUTE TO SECOND +SELECT (('10:00:13.123456')::INTERVAL MINUTE TO SECOND) -- fully parenthetized +SELECT _::INTERVAL MINUTE TO SECOND -- literals removed +SELECT '10:00:13.123456'::INTERVAL MINUTE TO SECOND -- identifiers removed + +parse +SELECT '10:00:13.123456'::INTERVAL MINUTE TO SECOND(3) +---- +SELECT '10:00:13.123456'::INTERVAL MINUTE TO SECOND(3) +SELECT (('10:00:13.123456')::INTERVAL MINUTE TO SECOND(3)) -- fully parenthetized +SELECT _::INTERVAL MINUTE TO SECOND(3) -- literals removed +SELECT '10:00:13.123456'::INTERVAL MINUTE TO SECOND(3) -- identifiers removed + + +parse +SELECT 'foo'::BOX2D +---- +SELECT 'foo'::BOX2D +SELECT (('foo')::BOX2D) -- fully parenthetized +SELECT _::BOX2D -- literals removed +SELECT 'foo'::BOX2D -- identifiers removed + +parse +SELECT 'foo'::GEOGRAPHY +---- +SELECT 'foo'::GEOGRAPHY +SELECT (('foo')::GEOGRAPHY) -- fully parenthetized +SELECT _::GEOGRAPHY -- literals removed +SELECT 'foo'::GEOGRAPHY -- identifiers removed + +parse +SELECT 'foo'::GEOGRAPHY(POINT,4326) +---- +SELECT 'foo'::GEOGRAPHY(POINT,4326) +SELECT (('foo')::GEOGRAPHY(POINT,4326)) -- fully parenthetized +SELECT _::GEOGRAPHY(POINT,4326) -- literals removed +SELECT 'foo'::GEOGRAPHY(POINT,4326) -- identifiers removed + +parse +SELECT 'foo'::GEOGRAPHY(POINT) +---- +SELECT 'foo'::GEOGRAPHY(POINT) +SELECT (('foo')::GEOGRAPHY(POINT)) -- fully parenthetized +SELECT _::GEOGRAPHY(POINT) -- literals removed +SELECT 'foo'::GEOGRAPHY(POINT) -- identifiers removed + +parse +SELECT 'foo'::GEOMETRY +---- +SELECT 'foo'::GEOMETRY +SELECT (('foo')::GEOMETRY) -- fully parenthetized +SELECT _::GEOMETRY -- literals removed +SELECT 'foo'::GEOMETRY -- identifiers removed + +parse +SELECT 'foo'::GEOMETRY(POINT) +---- +SELECT 'foo'::GEOMETRY(POINT) +SELECT (('foo')::GEOMETRY(POINT)) -- fully parenthetized +SELECT _::GEOMETRY(POINT) -- literals removed +SELECT 'foo'::GEOMETRY(POINT) -- identifiers removed + +parse +SELECT 'foo'::GEOMETRY(POINT,4326) +---- +SELECT 'foo'::GEOMETRY(POINT,4326) +SELECT (('foo')::GEOMETRY(POINT,4326)) -- fully parenthetized +SELECT _::GEOMETRY(POINT,4326) -- literals removed +SELECT 'foo'::GEOMETRY(POINT,4326) -- identifiers removed + +parse +SELECT '192.168.0.1'::INET +---- +SELECT '192.168.0.1'::INET +SELECT (('192.168.0.1')::INET) -- fully parenthetized +SELECT _::INET -- literals removed +SELECT '192.168.0.1'::INET -- identifiers removed + +parse +SELECT '192.168.0.1':::INET +---- +SELECT '192.168.0.1':::INET +SELECT (('192.168.0.1'):::INET) -- fully parenthetized +SELECT _:::INET -- literals removed +SELECT '192.168.0.1':::INET -- identifiers removed + +parse +SELECT INET '192.168.0.1' +---- +SELECT INET '192.168.0.1' +SELECT (INET ('192.168.0.1')) -- fully parenthetized +SELECT INET _ -- literals removed +SELECT inet AS _ -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT INET '192.168.0.1' -- identifiers removed + +parse +SELECT b <<= c +---- +SELECT inet_contained_by_or_equals(b, c) -- normalized! +SELECT (inet_contained_by_or_equals((b), (c))) -- fully parenthetized +SELECT inet_contained_by_or_equals(b, c) -- literals removed +SELECT inet_contained_by_or_equals(_, _) -- identifiers removed + +parse +SELECT b >>= c +---- +SELECT inet_contains_or_equals(b, c) -- normalized! +SELECT (inet_contains_or_equals((b), (c))) -- fully parenthetized +SELECT inet_contains_or_equals(b, c) -- literals removed +SELECT inet_contains_or_equals(_, _) -- identifiers removed + + +parse +SELECT 1:::REGTYPE +---- +SELECT 1:::REGTYPE +SELECT ((1):::REGTYPE) -- fully parenthetized +SELECT _:::REGTYPE -- literals removed +SELECT 1:::REGTYPE -- identifiers removed + +parse +SELECT 1:::REGPROC +---- +SELECT 1:::REGPROC +SELECT ((1):::REGPROC) -- fully parenthetized +SELECT _:::REGPROC -- literals removed +SELECT 1:::REGPROC -- identifiers removed + +parse +SELECT 1:::REGPROCEDURE +---- +SELECT 1:::REGPROCEDURE +SELECT ((1):::REGPROCEDURE) -- fully parenthetized +SELECT _:::REGPROCEDURE -- literals removed +SELECT 1:::REGPROCEDURE -- identifiers removed + +parse +SELECT 1:::REGCLASS +---- +SELECT 1:::REGCLASS +SELECT ((1):::REGCLASS) -- fully parenthetized +SELECT _:::REGCLASS -- literals removed +SELECT 1:::REGCLASS -- identifiers removed + +parse +SELECT 1:::REGNAMESPACE +---- +SELECT 1:::REGNAMESPACE +SELECT ((1):::REGNAMESPACE) -- fully parenthetized +SELECT _:::REGNAMESPACE -- literals removed +SELECT 1:::REGNAMESPACE -- identifiers removed + +parse +SELECT 'a' AS "12345" +---- +SELECT 'a' AS "12345" +SELECT ('a') AS "12345" -- fully parenthetized +SELECT _ AS "12345" -- literals removed +SELECT 'a' AS _ -- identifiers removed + +parse +SELECT 'a' AS clnm +---- +SELECT 'a' AS clnm +SELECT ('a') AS clnm -- fully parenthetized +SELECT _ AS clnm -- literals removed +SELECT 'a' AS _ -- identifiers removed + +parse +SELECT 'a' AS primary +---- +SELECT 'a' AS primary +SELECT ('a') AS primary -- fully parenthetized +SELECT _ AS primary -- literals removed +SELECT 'a' AS _ -- identifiers removed + +parse +SELECT 'a' AS like +---- +SELECT 'a' AS like +SELECT ('a') AS like -- fully parenthetized +SELECT _ AS like -- literals removed +SELECT 'a' AS _ -- identifiers removed + +parse +SELECT 0xf0 FROM t +---- +SELECT 0xf0 FROM t +SELECT (0xf0) FROM t -- fully parenthetized +SELECT _ FROM t -- literals removed +SELECT 0xf0 FROM _ -- identifiers removed + +parse +SELECT 0xF0 FROM t +---- +SELECT 0xF0 FROM t +SELECT (0xF0) FROM t -- fully parenthetized +SELECT _ FROM t -- literals removed +SELECT 0xF0 FROM _ -- identifiers removed + +parse +SELECT CAST(1 AS STRING) +---- +SELECT CAST(1 AS STRING) +SELECT (CAST((1) AS STRING)) -- fully parenthetized +SELECT CAST(_ AS STRING) -- literals removed +SELECT CAST(1 AS STRING) -- identifiers removed + +parse +SELECT CAST(1 AS _int8) +---- +SELECT CAST(1 AS INT8[]) -- normalized! +SELECT (CAST((1) AS INT8[])) -- fully parenthetized +SELECT CAST(_ AS INT8[]) -- literals removed +SELECT CAST(1 AS INT8[]) -- identifiers removed + +parse +SELECT CAST(1 AS "_int8") +---- +SELECT CAST(1 AS INT8[]) -- normalized! +SELECT (CAST((1) AS INT8[])) -- fully parenthetized +SELECT CAST(_ AS INT8[]) -- literals removed +SELECT CAST(1 AS INT8[]) -- identifiers removed + +parse +SELECT SERIAL8 'foo', 'foo'::SERIAL8 +---- +SELECT INT8 'foo', 'foo'::INT8 -- normalized! +SELECT (INT8 ('foo')), (('foo')::INT8) -- fully parenthetized +SELECT INT8 _, _::INT8 -- literals removed +SELECT int8 AS _, _::INT8 -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT INT8 'foo', 'foo'::INT8 -- identifiers removed + + +parse +SELECT ANNOTATE_TYPE(1, STRING) +---- +SELECT ANNOTATE_TYPE(1, STRING) +SELECT (ANNOTATE_TYPE((1), STRING)) -- fully parenthetized +SELECT ANNOTATE_TYPE(_, STRING) -- literals removed +SELECT ANNOTATE_TYPE(1, STRING) -- identifiers removed + +parse +SELECT (1 + 2).* +---- +SELECT (1 + 2).* +SELECT ((((1) + (2))).*) -- fully parenthetized +SELECT (_ + _).* -- literals removed +SELECT (1 + 2).* -- identifiers removed + +parse +SELECT (1 + 2).@1 +---- +SELECT (1 + 2).@1 +SELECT ((((1) + (2))).@1) -- fully parenthetized +SELECT (_ + _).@1 -- literals removed +SELECT (1 + 2).@1 -- identifiers removed + + +parse +SELECT (1 + 2).col +---- +SELECT (1 + 2).col +SELECT ((((1) + (2))).col) -- fully parenthetized +SELECT (_ + _).col -- literals removed +SELECT (1 + 2)._ -- identifiers removed + +parse +SELECT (abc.def).col +---- +SELECT (abc.def).col +SELECT (((abc.def)).col) -- fully parenthetized +SELECT (abc.def).col -- literals removed +SELECT (_._)._ -- identifiers removed + +parse +SELECT (i.keys).col +---- +SELECT (i.keys).col +SELECT (((i.keys)).col) -- fully parenthetized +SELECT (i.keys).col -- literals removed +SELECT (_._)._ -- identifiers removed + +parse +SELECT (i.keys).* +---- +SELECT (i.keys).* +SELECT (((i.keys)).*) -- fully parenthetized +SELECT (i.keys).* -- literals removed +SELECT (_._).* -- identifiers removed + +parse +SELECT (i.keys).@1 +---- +SELECT (i.keys).@1 +SELECT (((i.keys)).@1) -- fully parenthetized +SELECT (i.keys).@1 -- literals removed +SELECT (_._).@1 -- identifiers removed + +parse +SELECT (ARRAY['a', 'b', 'c']).name +---- +SELECT (ARRAY['a', 'b', 'c']).name +SELECT (((ARRAY[('a'), ('b'), ('c')])).name) -- fully parenthetized +SELECT (ARRAY[_, _, __more1__]).name -- literals removed +SELECT (ARRAY['a', 'b', 'c'])._ -- identifiers removed + +parse +SELECT 'a' LIKE '\a' ESCAPE '\' +---- +SELECT like_escape('a', e'\\a', e'\\') -- normalized! +SELECT (like_escape(('a'), (e'\\a'), (e'\\'))) -- fully parenthetized +SELECT like_escape(_, _, _) -- literals removed +SELECT like_escape('a', e'\\a', e'\\') -- identifiers removed + +parse +SELECT '\abc\' LIKE '-\___-\' ESCAPE '-' +---- +SELECT like_escape(e'\\abc\\', e'-\\___-\\', '-') -- normalized! +SELECT (like_escape((e'\\abc\\'), (e'-\\___-\\'), ('-'))) -- fully parenthetized +SELECT like_escape(_, _, _) -- literals removed +SELECT like_escape(e'\\abc\\', e'-\\___-\\', '-') -- identifiers removed + +parse +SELECT 'a' LIKE '\a' ESCAPE '' +---- +SELECT like_escape('a', e'\\a', '') -- normalized! +SELECT (like_escape(('a'), (e'\\a'), (''))) -- fully parenthetized +SELECT like_escape(_, _, _) -- literals removed +SELECT like_escape('a', e'\\a', '') -- identifiers removed + +parse +SELECT 'a' NOT LIKE '\a' ESCAPE '\' +---- +SELECT not_like_escape('a', e'\\a', e'\\') -- normalized! +SELECT (not_like_escape(('a'), (e'\\a'), (e'\\'))) -- fully parenthetized +SELECT not_like_escape(_, _, _) -- literals removed +SELECT not_like_escape('a', e'\\a', e'\\') -- identifiers removed + +parse +SELECT '\abc\' NOT LIKE '-\___-\' ESCAPE '-' +---- +SELECT not_like_escape(e'\\abc\\', e'-\\___-\\', '-') -- normalized! +SELECT (not_like_escape((e'\\abc\\'), (e'-\\___-\\'), ('-'))) -- fully parenthetized +SELECT not_like_escape(_, _, _) -- literals removed +SELECT not_like_escape(e'\\abc\\', e'-\\___-\\', '-') -- identifiers removed + +parse +SELECT 'a' NOT LIKE '\a' ESCAPE '' +---- +SELECT not_like_escape('a', e'\\a', '') -- normalized! +SELECT (not_like_escape(('a'), (e'\\a'), (''))) -- fully parenthetized +SELECT not_like_escape(_, _, _) -- literals removed +SELECT not_like_escape('a', e'\\a', '') -- identifiers removed + +parse +SELECT 'a' ILIKE '\a' ESCAPE '\' +---- +SELECT ilike_escape('a', e'\\a', e'\\') -- normalized! +SELECT (ilike_escape(('a'), (e'\\a'), (e'\\'))) -- fully parenthetized +SELECT ilike_escape(_, _, _) -- literals removed +SELECT ilike_escape('a', e'\\a', e'\\') -- identifiers removed + +parse +SELECT '\abc\' ILIKE '-\___-\' ESCAPE '-' +---- +SELECT ilike_escape(e'\\abc\\', e'-\\___-\\', '-') -- normalized! +SELECT (ilike_escape((e'\\abc\\'), (e'-\\___-\\'), ('-'))) -- fully parenthetized +SELECT ilike_escape(_, _, _) -- literals removed +SELECT ilike_escape(e'\\abc\\', e'-\\___-\\', '-') -- identifiers removed + +parse +SELECT 'a' ILIKE '\a' ESCAPE '' +---- +SELECT ilike_escape('a', e'\\a', '') -- normalized! +SELECT (ilike_escape(('a'), (e'\\a'), (''))) -- fully parenthetized +SELECT ilike_escape(_, _, _) -- literals removed +SELECT ilike_escape('a', e'\\a', '') -- identifiers removed + +parse +SELECT 'a' NOT ILIKE '\a' ESCAPE '\' +---- +SELECT not_ilike_escape('a', e'\\a', e'\\') -- normalized! +SELECT (not_ilike_escape(('a'), (e'\\a'), (e'\\'))) -- fully parenthetized +SELECT not_ilike_escape(_, _, _) -- literals removed +SELECT not_ilike_escape('a', e'\\a', e'\\') -- identifiers removed + +parse +SELECT '\abc\' NOT ILIKE '-\___-\' ESCAPE '-' +---- +SELECT not_ilike_escape(e'\\abc\\', e'-\\___-\\', '-') -- normalized! +SELECT (not_ilike_escape((e'\\abc\\'), (e'-\\___-\\'), ('-'))) -- fully parenthetized +SELECT not_ilike_escape(_, _, _) -- literals removed +SELECT not_ilike_escape(e'\\abc\\', e'-\\___-\\', '-') -- identifiers removed + +parse +SELECT 'a' NOT ILIKE '\a' ESCAPE '' +---- +SELECT not_ilike_escape('a', e'\\a', '') -- normalized! +SELECT (not_ilike_escape(('a'), (e'\\a'), (''))) -- fully parenthetized +SELECT not_ilike_escape(_, _, _) -- literals removed +SELECT not_ilike_escape('a', e'\\a', '') -- identifiers removed + +parse +SELECT 'a' SIMILAR TO '\a' ESCAPE '\' +---- +SELECT similar_to_escape('a', e'\\a', e'\\') -- normalized! +SELECT (similar_to_escape(('a'), (e'\\a'), (e'\\'))) -- fully parenthetized +SELECT similar_to_escape(_, _, _) -- literals removed +SELECT similar_to_escape('a', e'\\a', e'\\') -- identifiers removed + +parse +SELECT '\abc\' SIMILAR TO '-\___-\' ESCAPE '-' +---- +SELECT similar_to_escape(e'\\abc\\', e'-\\___-\\', '-') -- normalized! +SELECT (similar_to_escape((e'\\abc\\'), (e'-\\___-\\'), ('-'))) -- fully parenthetized +SELECT similar_to_escape(_, _, _) -- literals removed +SELECT similar_to_escape(e'\\abc\\', e'-\\___-\\', '-') -- identifiers removed + +parse +SELECT 'a' SIMILAR TO '\a' ESCAPE '' +---- +SELECT similar_to_escape('a', e'\\a', '') -- normalized! +SELECT (similar_to_escape(('a'), (e'\\a'), (''))) -- fully parenthetized +SELECT similar_to_escape(_, _, _) -- literals removed +SELECT similar_to_escape('a', e'\\a', '') -- identifiers removed + +parse +SELECT 'a' NOT SIMILAR TO '\a' ESCAPE '\' +---- +SELECT not_similar_to_escape('a', e'\\a', e'\\') -- normalized! +SELECT (not_similar_to_escape(('a'), (e'\\a'), (e'\\'))) -- fully parenthetized +SELECT not_similar_to_escape(_, _, _) -- literals removed +SELECT not_similar_to_escape('a', e'\\a', e'\\') -- identifiers removed + +parse +SELECT '\abc\' NOT SIMILAR TO '-\___-\' ESCAPE '-' +---- +SELECT not_similar_to_escape(e'\\abc\\', e'-\\___-\\', '-') -- normalized! +SELECT (not_similar_to_escape((e'\\abc\\'), (e'-\\___-\\'), ('-'))) -- fully parenthetized +SELECT not_similar_to_escape(_, _, _) -- literals removed +SELECT not_similar_to_escape(e'\\abc\\', e'-\\___-\\', '-') -- identifiers removed + +parse +SELECT 'a' NOT SIMILAR TO '\a' ESCAPE '' +---- +SELECT not_similar_to_escape('a', e'\\a', '') -- normalized! +SELECT (not_similar_to_escape(('a'), (e'\\a'), (''))) -- fully parenthetized +SELECT not_similar_to_escape(_, _, _) -- literals removed +SELECT not_similar_to_escape('a', e'\\a', '') -- identifiers removed + +parse +SELECT $$a'a$$ +---- +SELECT e'a\'a' -- normalized! +SELECT (e'a\'a') -- fully parenthetized +SELECT _ -- literals removed +SELECT e'a\'a' -- identifiers removed + +parse +SELECT $$a\\na$$ +---- +SELECT e'a\\\\na' -- normalized! +SELECT (e'a\\\\na') -- fully parenthetized +SELECT _ -- literals removed +SELECT e'a\\\\na' -- identifiers removed + +parse +SELECT $select$\\n$select$ +---- +SELECT e'\\\\n' -- normalized! +SELECT (e'\\\\n') -- fully parenthetized +SELECT _ -- literals removed +SELECT e'\\\\n' -- identifiers removed + +parse +SELECT $$a"a$$ +---- +SELECT 'a"a' -- normalized! +SELECT ('a"a') -- fully parenthetized +SELECT _ -- literals removed +SELECT 'a"a' -- identifiers removed + +parse +SELECT $$full$$ +---- +SELECT 'full' -- normalized! +SELECT ('full') -- fully parenthetized +SELECT _ -- literals removed +SELECT 'full' -- identifiers removed + +parse +SELECT $select$full$select$ +---- +SELECT 'full' -- normalized! +SELECT ('full') -- fully parenthetized +SELECT _ -- literals removed +SELECT 'full' -- identifiers removed + +parse +SELECT $select$a$$b$select$ +---- +SELECT 'a$$b' -- normalized! +SELECT ('a$$b') -- fully parenthetized +SELECT _ -- literals removed +SELECT 'a$$b' -- identifiers removed + +parse +SELECT $$Dianne's horse$$ +---- +SELECT e'Dianne\'s horse' -- normalized! +SELECT (e'Dianne\'s horse') -- fully parenthetized +SELECT _ -- literals removed +SELECT e'Dianne\'s horse' -- identifiers removed + +parse +SELECT $SomeTag$Dianne's horse$SomeTag$ +---- +SELECT e'Dianne\'s horse' -- normalized! +SELECT (e'Dianne\'s horse') -- fully parenthetized +SELECT _ -- literals removed +SELECT e'Dianne\'s horse' -- identifiers removed + +parse +SELECT $function$ +BEGIN +RETURN ($1 ~ $q$[\t\r\n\v\\]$q$); +END; +$function$ +---- +SELECT e'\nBEGIN\nRETURN ($1 ~ $q$[\\t\\r\\n\\v\\\\]$q$);\nEND;\n' -- normalized! +SELECT (e'\nBEGIN\nRETURN ($1 ~ $q$[\\t\\r\\n\\v\\\\]$q$);\nEND;\n') -- fully parenthetized +SELECT _ -- literals removed +SELECT e'\nBEGIN\nRETURN ($1 ~ $q$[\\t\\r\\n\\v\\\\]$q$);\nEND;\n' -- identifiers removed + +parse +SELECT a IS NAN +---- +SELECT a = 'NaN' -- normalized! +SELECT ((a) = ('NaN')) -- fully parenthetized +SELECT a = _ -- literals removed +SELECT _ = 'NaN' -- identifiers removed + +parse +SELECT a IS NOT NAN +---- +SELECT a != 'NaN' -- normalized! +SELECT ((a) != ('NaN')) -- fully parenthetized +SELECT a != _ -- literals removed +SELECT _ != 'NaN' -- identifiers removed + +parse +SELECT 1+COALESCE(NULL, 'a', x)-ARRAY[3.14] +---- +SELECT (1 + COALESCE(NULL, 'a', x)) - ARRAY[3.14] -- normalized! +SELECT ((((1) + (COALESCE((NULL), ('a'), (x))))) - (ARRAY[(3.14)])) -- fully parenthetized +SELECT (_ + COALESCE(_, _, x)) - ARRAY[_] -- literals removed +SELECT (1 + COALESCE(NULL, 'a', _)) - ARRAY[3.14] -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/session_queries b/pkg/sql/parser/testdata/parse/session_queries new file mode 100644 index 000000000000..5fba87777222 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/session_queries @@ -0,0 +1,80 @@ +parse +CANCEL QUERY a +---- +CANCEL QUERIES VALUES (a) -- normalized! +CANCEL QUERIES VALUES ((a)) -- fully parenthetized +CANCEL QUERIES VALUES (a) -- literals removed +CANCEL QUERIES VALUES (_) -- identifiers removed + +parse +CANCEL QUERY IF EXISTS a +---- +CANCEL QUERIES IF EXISTS VALUES (a) -- normalized! +CANCEL QUERIES IF EXISTS VALUES ((a)) -- fully parenthetized +CANCEL QUERIES IF EXISTS VALUES (a) -- literals removed +CANCEL QUERIES IF EXISTS VALUES (_) -- identifiers removed + + +parse +CANCEL QUERIES SELECT a +---- +CANCEL QUERIES SELECT a +CANCEL QUERIES SELECT (a) -- fully parenthetized +CANCEL QUERIES SELECT a -- literals removed +CANCEL QUERIES SELECT _ -- identifiers removed + +parse +EXPLAIN CANCEL QUERIES SELECT a +---- +EXPLAIN CANCEL QUERIES SELECT a +EXPLAIN CANCEL QUERIES SELECT (a) -- fully parenthetized +EXPLAIN CANCEL QUERIES SELECT a -- literals removed +EXPLAIN CANCEL QUERIES SELECT _ -- identifiers removed + +parse +CANCEL SESSION a +---- +CANCEL SESSIONS VALUES (a) -- normalized! +CANCEL SESSIONS VALUES ((a)) -- fully parenthetized +CANCEL SESSIONS VALUES (a) -- literals removed +CANCEL SESSIONS VALUES (_) -- identifiers removed + +parse +CANCEL SESSION IF EXISTS a +---- +CANCEL SESSIONS IF EXISTS VALUES (a) -- normalized! +CANCEL SESSIONS IF EXISTS VALUES ((a)) -- fully parenthetized +CANCEL SESSIONS IF EXISTS VALUES (a) -- literals removed +CANCEL SESSIONS IF EXISTS VALUES (_) -- identifiers removed + +parse +CANCEL SESSIONS SELECT a +---- +CANCEL SESSIONS SELECT a +CANCEL SESSIONS SELECT (a) -- fully parenthetized +CANCEL SESSIONS SELECT a -- literals removed +CANCEL SESSIONS SELECT _ -- identifiers removed + +parse +EXPLAIN CANCEL SESSIONS SELECT a +---- +EXPLAIN CANCEL SESSIONS SELECT a +EXPLAIN CANCEL SESSIONS SELECT (a) -- fully parenthetized +EXPLAIN CANCEL SESSIONS SELECT a -- literals removed +EXPLAIN CANCEL SESSIONS SELECT _ -- identifiers removed + +parse +CANCEL QUERIES IF EXISTS SELECT a +---- +CANCEL QUERIES IF EXISTS SELECT a +CANCEL QUERIES IF EXISTS SELECT (a) -- fully parenthetized +CANCEL QUERIES IF EXISTS SELECT a -- literals removed +CANCEL QUERIES IF EXISTS SELECT _ -- identifiers removed + +parse +CANCEL SESSIONS IF EXISTS SELECT a +---- +CANCEL SESSIONS IF EXISTS SELECT a +CANCEL SESSIONS IF EXISTS SELECT (a) -- fully parenthetized +CANCEL SESSIONS IF EXISTS SELECT a -- literals removed +CANCEL SESSIONS IF EXISTS SELECT _ -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/set b/pkg/sql/parser/testdata/parse/set new file mode 100644 index 000000000000..8b009f586d37 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/set @@ -0,0 +1,486 @@ +parse +SET a = 3 +---- +SET a = 3 +SET a = (3) -- fully parenthetized +SET a = _ -- literals removed +SET a = 3 -- identifiers removed + +parse +EXPLAIN SET a = 3 +---- +EXPLAIN SET a = 3 +EXPLAIN SET a = (3) -- fully parenthetized +EXPLAIN SET a = _ -- literals removed +EXPLAIN SET a = 3 -- identifiers removed + +parse +SET a = INDEX +---- +SET a = "index" -- normalized! +SET a = ("index") -- fully parenthetized +SET a = "index" -- literals removed +SET a = _ -- identifiers removed + +parse +SET a = NOTHING +---- +SET a = "nothing" -- normalized! +SET a = ("nothing") -- fully parenthetized +SET a = "nothing" -- literals removed +SET a = _ -- identifiers removed + + +parse +SET a = 3, 4 +---- +SET a = 3, 4 +SET a = (3), (4) -- fully parenthetized +SET a = _, _ -- literals removed +SET a = 3, 4 -- identifiers removed + +parse +SET a = '3' +---- +SET a = '3' +SET a = ('3') -- fully parenthetized +SET a = _ -- literals removed +SET a = '3' -- identifiers removed + +parse +SET a = 3.0 +---- +SET a = 3.0 +SET a = (3.0) -- fully parenthetized +SET a = _ -- literals removed +SET a = 3.0 -- identifiers removed + +parse +SET a = $1 +---- +SET a = $1 +SET a = ($1) -- fully parenthetized +SET a = $1 -- literals removed +SET a = $1 -- identifiers removed + +parse +SET a = off +---- +SET a = off +SET a = (off) -- fully parenthetized +SET a = off -- literals removed +SET a = _ -- identifiers removed + +parse +SET a = on +---- +SET a = "on" -- normalized! +SET a = ("on") -- fully parenthetized +SET a = "on" -- literals removed +SET a = _ -- identifiers removed + +parse +SET a = default +---- +SET a = DEFAULT -- normalized! +SET a = (DEFAULT) -- fully parenthetized +SET a = DEFAULT -- literals removed +SET a = DEFAULT -- identifiers removed + + +parse +SET TRANSACTION READ ONLY +---- +SET TRANSACTION READ ONLY +SET TRANSACTION READ ONLY -- fully parenthetized +SET TRANSACTION READ ONLY -- literals removed +SET TRANSACTION READ ONLY -- identifiers removed + +parse +SET TRANSACTION READ WRITE +---- +SET TRANSACTION READ WRITE +SET TRANSACTION READ WRITE -- fully parenthetized +SET TRANSACTION READ WRITE -- literals removed +SET TRANSACTION READ WRITE -- identifiers removed + +parse +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE +---- +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE -- fully parenthetized +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE -- literals removed +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE -- identifiers removed + +parse +SET TRANSACTION PRIORITY LOW +---- +SET TRANSACTION PRIORITY LOW +SET TRANSACTION PRIORITY LOW -- fully parenthetized +SET TRANSACTION PRIORITY LOW -- literals removed +SET TRANSACTION PRIORITY LOW -- identifiers removed + +parse +SET TRANSACTION PRIORITY NORMAL +---- +SET TRANSACTION PRIORITY NORMAL +SET TRANSACTION PRIORITY NORMAL -- fully parenthetized +SET TRANSACTION PRIORITY NORMAL -- literals removed +SET TRANSACTION PRIORITY NORMAL -- identifiers removed + +parse +SET TRANSACTION PRIORITY HIGH +---- +SET TRANSACTION PRIORITY HIGH +SET TRANSACTION PRIORITY HIGH -- fully parenthetized +SET TRANSACTION PRIORITY HIGH -- literals removed +SET TRANSACTION PRIORITY HIGH -- identifiers removed + +parse +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH +---- +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH -- fully parenthetized +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH -- literals removed +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH -- identifiers removed + +parse +SET TRANSACTION DEFERRABLE +---- +SET TRANSACTION DEFERRABLE +SET TRANSACTION DEFERRABLE -- fully parenthetized +SET TRANSACTION DEFERRABLE -- literals removed +SET TRANSACTION DEFERRABLE -- identifiers removed + +parse +SET TRANSACTION NOT DEFERRABLE +---- +SET TRANSACTION NOT DEFERRABLE +SET TRANSACTION NOT DEFERRABLE -- fully parenthetized +SET TRANSACTION NOT DEFERRABLE -- literals removed +SET TRANSACTION NOT DEFERRABLE -- identifiers removed + +parse +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH, AS OF SYSTEM TIME '-1s', NOT DEFERRABLE +---- +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH, AS OF SYSTEM TIME '-1s', NOT DEFERRABLE +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH, AS OF SYSTEM TIME ('-1s'), NOT DEFERRABLE -- fully parenthetized +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH, AS OF SYSTEM TIME _, NOT DEFERRABLE -- literals removed +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY HIGH, AS OF SYSTEM TIME '-1s', NOT DEFERRABLE -- identifiers removed + +parse +SET TRACING = off +---- +SET TRACING = off +SET TRACING = (off) -- fully parenthetized +SET TRACING = off -- literals removed +SET TRACING = _ -- identifiers removed + +parse +EXPLAIN SET TRACING = off +---- +EXPLAIN SET TRACING = off +EXPLAIN SET TRACING = (off) -- fully parenthetized +EXPLAIN SET TRACING = off -- literals removed +EXPLAIN SET TRACING = _ -- identifiers removed + +parse +SET TRACING TO off +---- +SET TRACING = off -- normalized! +SET TRACING = (off) -- fully parenthetized +SET TRACING = off -- literals removed +SET TRACING = _ -- identifiers removed + +parse +SET TRACING = 'cluster', 'kv' +---- +SET TRACING = 'cluster', 'kv' +SET TRACING = ('cluster'), ('kv') -- fully parenthetized +SET TRACING = _, _ -- literals removed +SET TRACING = 'cluster', 'kv' -- identifiers removed + +parse +SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE +---- +SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE +SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE -- fully parenthetized +SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE -- literals removed +SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE -- identifiers removed + +parse +SET CLUSTER SETTING a = 3 +---- +SET CLUSTER SETTING a = 3 +SET CLUSTER SETTING a = (3) -- fully parenthetized +SET CLUSTER SETTING a = _ -- literals removed +SET CLUSTER SETTING a = 3 -- identifiers removed + +parse +EXPLAIN SET CLUSTER SETTING a = 3 +---- +EXPLAIN SET CLUSTER SETTING a = 3 +EXPLAIN SET CLUSTER SETTING a = (3) -- fully parenthetized +EXPLAIN SET CLUSTER SETTING a = _ -- literals removed +EXPLAIN SET CLUSTER SETTING a = 3 -- identifiers removed + +parse +SET CLUSTER SETTING a = '3s' +---- +SET CLUSTER SETTING a = '3s' +SET CLUSTER SETTING a = ('3s') -- fully parenthetized +SET CLUSTER SETTING a = _ -- literals removed +SET CLUSTER SETTING a = '3s' -- identifiers removed + +parse +SET CLUSTER SETTING a = '3' +---- +SET CLUSTER SETTING a = '3' +SET CLUSTER SETTING a = ('3') -- fully parenthetized +SET CLUSTER SETTING a = _ -- literals removed +SET CLUSTER SETTING a = '3' -- identifiers removed + +parse +SET CLUSTER SETTING a = 3.0 +---- +SET CLUSTER SETTING a = 3.0 +SET CLUSTER SETTING a = (3.0) -- fully parenthetized +SET CLUSTER SETTING a = _ -- literals removed +SET CLUSTER SETTING a = 3.0 -- identifiers removed + +parse +SET CLUSTER SETTING a = $1 +---- +SET CLUSTER SETTING a = $1 +SET CLUSTER SETTING a = ($1) -- fully parenthetized +SET CLUSTER SETTING a = $1 -- literals removed +SET CLUSTER SETTING a = $1 -- identifiers removed + +parse +SET CLUSTER SETTING a = off +---- +SET CLUSTER SETTING a = off +SET CLUSTER SETTING a = (off) -- fully parenthetized +SET CLUSTER SETTING a = off -- literals removed +SET CLUSTER SETTING a = _ -- identifiers removed + + +parse +SET CLUSTER SETTING a = on +---- +SET CLUSTER SETTING a = "on" -- normalized! +SET CLUSTER SETTING a = ("on") -- fully parenthetized +SET CLUSTER SETTING a = "on" -- literals removed +SET CLUSTER SETTING a = _ -- identifiers removed + +parse +SET CLUSTER SETTING a TO 1 +---- +SET CLUSTER SETTING a = 1 -- normalized! +SET CLUSTER SETTING a = (1) -- fully parenthetized +SET CLUSTER SETTING a = _ -- literals removed +SET CLUSTER SETTING a = 1 -- identifiers removed + + +parse +DISCARD ALL +---- +DISCARD ALL +DISCARD ALL -- fully parenthetized +DISCARD ALL -- literals removed +DISCARD ALL -- identifiers removed + + +parse +SET ROW (1, true, NULL) +---- +SET ROW (1, true, NULL) +SET ROW ((1), (true), (NULL)) -- fully parenthetized +SET ROW (_, _, _) -- literals removed +SET ROW (1, true, NULL) -- identifiers removed + + +parse +SET SCHEMA 'public' +---- +SET search_path = 'public' -- normalized! +SET search_path = ('public') -- fully parenthetized +SET search_path = _ -- literals removed +SET search_path = 'public' -- identifiers removed + +parse +SET TIME ZONE 'pst8pdt' +---- +SET timezone = 'pst8pdt' -- normalized! +SET timezone = ('pst8pdt') -- fully parenthetized +SET timezone = _ -- literals removed +SET timezone = 'pst8pdt' -- identifiers removed + +parse +SET TIME ZONE 'Europe/Rome' +---- +SET timezone = 'Europe/Rome' -- normalized! +SET timezone = ('Europe/Rome') -- fully parenthetized +SET timezone = _ -- literals removed +SET timezone = 'Europe/Rome' -- identifiers removed + +parse +SET TIME ZONE -7 +---- +SET timezone = -7 -- normalized! +SET timezone = (-7) -- fully parenthetized +SET timezone = _ -- literals removed +SET timezone = -7 -- identifiers removed + +parse +SET TIME ZONE -7.3 +---- +SET timezone = -7.3 -- normalized! +SET timezone = (-7.3) -- fully parenthetized +SET timezone = _ -- literals removed +SET timezone = -7.3 -- identifiers removed + +parse +SET TIME ZONE DEFAULT +---- +SET timezone = DEFAULT -- normalized! +SET timezone = (DEFAULT) -- fully parenthetized +SET timezone = DEFAULT -- literals removed +SET timezone = DEFAULT -- identifiers removed + +parse +SET TIME ZONE LOCAL +---- +SET timezone = 'local' -- normalized! +SET timezone = ('local') -- fully parenthetized +SET timezone = _ -- literals removed +SET timezone = 'local' -- identifiers removed + +parse +SET TIME ZONE pst8pdt +---- +SET timezone = 'pst8pdt' -- normalized! +SET timezone = ('pst8pdt') -- fully parenthetized +SET timezone = _ -- literals removed +SET timezone = 'pst8pdt' -- identifiers removed + +parse +SET TIME ZONE "Europe/Rome" +---- +SET timezone = 'Europe/Rome' -- normalized! +SET timezone = ('Europe/Rome') -- fully parenthetized +SET timezone = _ -- literals removed +SET timezone = 'Europe/Rome' -- identifiers removed + +parse +SET TIME ZONE INTERVAL '-7h' +---- +SET timezone = '-07:00:00' -- normalized! +SET timezone = ('-07:00:00') -- fully parenthetized +SET timezone = _ -- literals removed +SET timezone = '-07:00:00' -- identifiers removed + +parse +SET TIME ZONE INTERVAL(3) '-7h' +---- +SET timezone = '-07:00:00' -- normalized! +SET timezone = ('-07:00:00') -- fully parenthetized +SET timezone = _ -- literals removed +SET timezone = '-07:00:00' -- identifiers removed + +parse +SET TIME ZONE INTERVAL '-7h0m5s' HOUR TO MINUTE +---- +SET timezone = '-06:59:00' -- normalized! +SET timezone = ('-06:59:00') -- fully parenthetized +SET timezone = _ -- literals removed +SET timezone = '-06:59:00' -- identifiers removed + + +parse +SET TRANSACTION PRIORITY NORMAL, ISOLATION LEVEL SERIALIZABLE +---- +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY NORMAL -- normalized! +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY NORMAL -- fully parenthetized +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY NORMAL -- literals removed +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, PRIORITY NORMAL -- identifiers removed + +parse +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE READ WRITE +---- +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ WRITE -- normalized! +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ WRITE -- fully parenthetized +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ WRITE -- literals removed +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ WRITE -- identifiers removed + +parse +SET TRANSACTION ISOLATION LEVEL SNAPSHOT READ ONLY +---- +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ ONLY -- normalized! +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ ONLY -- fully parenthetized +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ ONLY -- literals removed +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ ONLY -- identifiers removed + +parse +USE foo +---- +SET database = foo -- normalized! +SET database = (foo) -- fully parenthetized +SET database = foo -- literals removed +SET database = _ -- identifiers removed + +parse +SET NAMES foo +---- +SET client_encoding = foo -- normalized! +SET client_encoding = (foo) -- fully parenthetized +SET client_encoding = foo -- literals removed +SET client_encoding = _ -- identifiers removed + +parse +SET NAMES 'foo' +---- +SET client_encoding = 'foo' -- normalized! +SET client_encoding = ('foo') -- fully parenthetized +SET client_encoding = _ -- literals removed +SET client_encoding = 'foo' -- identifiers removed + +parse +SET NAMES DEFAULT +---- +SET client_encoding = DEFAULT -- normalized! +SET client_encoding = (DEFAULT) -- fully parenthetized +SET client_encoding = DEFAULT -- literals removed +SET client_encoding = DEFAULT -- identifiers removed + +parse +SET NAMES +---- +SET client_encoding = DEFAULT -- normalized! +SET client_encoding = (DEFAULT) -- fully parenthetized +SET client_encoding = DEFAULT -- literals removed +SET client_encoding = DEFAULT -- identifiers removed + +parse +RESET a +---- +SET a = DEFAULT -- normalized! +SET a = (DEFAULT) -- fully parenthetized +SET a = DEFAULT -- literals removed +SET a = DEFAULT -- identifiers removed + +parse +RESET CLUSTER SETTING a +---- +SET CLUSTER SETTING a = DEFAULT -- normalized! +SET CLUSTER SETTING a = (DEFAULT) -- fully parenthetized +SET CLUSTER SETTING a = DEFAULT -- literals removed +SET CLUSTER SETTING a = DEFAULT -- identifiers removed + +parse +RESET NAMES +---- +SET client_encoding = DEFAULT -- normalized! +SET client_encoding = (DEFAULT) -- fully parenthetized +SET client_encoding = DEFAULT -- literals removed +SET client_encoding = DEFAULT -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/show b/pkg/sql/parser/testdata/parse/show new file mode 100644 index 000000000000..8362424c56a0 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/show @@ -0,0 +1,1520 @@ +## Session var names never contain PII and should be distinguished +## during anonymization for feature tracking purposes. + +parse +SHOW barfoo +---- +SHOW barfoo +SHOW barfoo -- fully parenthetized +SHOW barfoo -- literals removed +SHOW barfoo -- identifiers removed + +parse +EXPLAIN SHOW barfoo +---- +EXPLAIN SHOW barfoo +EXPLAIN SHOW barfoo -- fully parenthetized +EXPLAIN SHOW barfoo -- literals removed +EXPLAIN SHOW barfoo -- identifiers removed + + + +parse +SHOW database +---- +SHOW database +SHOW database -- fully parenthetized +SHOW database -- literals removed +SHOW database -- identifiers removed + +parse +SHOW timezone +---- +SHOW timezone +SHOW timezone -- fully parenthetized +SHOW timezone -- literals removed +SHOW timezone -- identifiers removed + +parse +SHOW "BLAH" +---- +SHOW "BLAH" +SHOW "BLAH" -- fully parenthetized +SHOW "BLAH" -- literals removed +SHOW "BLAH" -- identifiers removed + +parse +SHOW SESSION barfoo +---- +SHOW barfoo -- normalized! +SHOW barfoo -- fully parenthetized +SHOW barfoo -- literals removed +SHOW barfoo -- identifiers removed + +parse +SHOW SESSION database +---- +SHOW database -- normalized! +SHOW database -- fully parenthetized +SHOW database -- literals removed +SHOW database -- identifiers removed + +parse +SHOW SESSION TIME ZONE +---- +SHOW timezone -- normalized! +SHOW timezone -- fully parenthetized +SHOW timezone -- literals removed +SHOW timezone -- identifiers removed + +parse +SHOW SESSION TIMEZONE +---- +SHOW timezone -- normalized! +SHOW timezone -- fully parenthetized +SHOW timezone -- literals removed +SHOW timezone -- identifiers removed + +## Cluster setting names never contain PII and should be distinguished +## for feature tracking purposes. + +parse +SHOW CLUSTER SETTING a +---- +SHOW CLUSTER SETTING a +SHOW CLUSTER SETTING a -- fully parenthetized +SHOW CLUSTER SETTING a -- literals removed +SHOW CLUSTER SETTING a -- identifiers removed + +parse +EXPLAIN SHOW CLUSTER SETTING a +---- +EXPLAIN SHOW CLUSTER SETTING a +EXPLAIN SHOW CLUSTER SETTING a -- fully parenthetized +EXPLAIN SHOW CLUSTER SETTING a -- literals removed +EXPLAIN SHOW CLUSTER SETTING a -- identifiers removed + +parse +SHOW ALL CLUSTER SETTINGS +---- +SHOW ALL CLUSTER SETTINGS +SHOW ALL CLUSTER SETTINGS -- fully parenthetized +SHOW ALL CLUSTER SETTINGS -- literals removed +SHOW ALL CLUSTER SETTINGS -- identifiers removed + +parse +SHOW CLUSTER SETTING ALL +---- +SHOW ALL CLUSTER SETTINGS -- normalized! +SHOW ALL CLUSTER SETTINGS -- fully parenthetized +SHOW ALL CLUSTER SETTINGS -- literals removed +SHOW ALL CLUSTER SETTINGS -- identifiers removed + +parse +SHOW PUBLIC CLUSTER SETTINGS +---- +SHOW PUBLIC CLUSTER SETTINGS +SHOW PUBLIC CLUSTER SETTINGS -- fully parenthetized +SHOW PUBLIC CLUSTER SETTINGS -- literals removed +SHOW PUBLIC CLUSTER SETTINGS -- identifiers removed + +parse +SHOW CLUSTER SETTINGS +---- +SHOW PUBLIC CLUSTER SETTINGS -- normalized! +SHOW PUBLIC CLUSTER SETTINGS -- fully parenthetized +SHOW PUBLIC CLUSTER SETTINGS -- literals removed +SHOW PUBLIC CLUSTER SETTINGS -- identifiers removed + +parse +SHOW DATABASES +---- +SHOW DATABASES +SHOW DATABASES -- fully parenthetized +SHOW DATABASES -- literals removed +SHOW DATABASES -- identifiers removed + +parse +EXPLAIN SHOW DATABASES +---- +EXPLAIN SHOW DATABASES +EXPLAIN SHOW DATABASES -- fully parenthetized +EXPLAIN SHOW DATABASES -- literals removed +EXPLAIN SHOW DATABASES -- identifiers removed + +parse +SHOW ENUMS +---- +SHOW ENUMS +SHOW ENUMS -- fully parenthetized +SHOW ENUMS -- literals removed +SHOW ENUMS -- identifiers removed + +parse +EXPLAIN SHOW ENUMS +---- +EXPLAIN SHOW ENUMS +EXPLAIN SHOW ENUMS -- fully parenthetized +EXPLAIN SHOW ENUMS -- literals removed +EXPLAIN SHOW ENUMS -- identifiers removed + +parse +SHOW TYPES +---- +SHOW TYPES +SHOW TYPES -- fully parenthetized +SHOW TYPES -- literals removed +SHOW TYPES -- identifiers removed + +parse +EXPLAIN SHOW TYPES +---- +EXPLAIN SHOW TYPES +EXPLAIN SHOW TYPES -- fully parenthetized +EXPLAIN SHOW TYPES -- literals removed +EXPLAIN SHOW TYPES -- identifiers removed + +parse +SHOW SCHEMAS +---- +SHOW SCHEMAS +SHOW SCHEMAS -- fully parenthetized +SHOW SCHEMAS -- literals removed +SHOW SCHEMAS -- identifiers removed + +parse +EXPLAIN SHOW SCHEMAS +---- +EXPLAIN SHOW SCHEMAS +EXPLAIN SHOW SCHEMAS -- fully parenthetized +EXPLAIN SHOW SCHEMAS -- literals removed +EXPLAIN SHOW SCHEMAS -- identifiers removed + +parse +SHOW SCHEMAS FROM a +---- +SHOW SCHEMAS FROM a +SHOW SCHEMAS FROM a -- fully parenthetized +SHOW SCHEMAS FROM a -- literals removed +SHOW SCHEMAS FROM _ -- identifiers removed + +parse +SHOW SEQUENCES +---- +SHOW SEQUENCES +SHOW SEQUENCES -- fully parenthetized +SHOW SEQUENCES -- literals removed +SHOW SEQUENCES -- identifiers removed + +parse +EXPLAIN SHOW SEQUENCES +---- +EXPLAIN SHOW SEQUENCES +EXPLAIN SHOW SEQUENCES -- fully parenthetized +EXPLAIN SHOW SEQUENCES -- literals removed +EXPLAIN SHOW SEQUENCES -- identifiers removed + +parse +SHOW SEQUENCES FROM a +---- +SHOW SEQUENCES FROM a +SHOW SEQUENCES FROM a -- fully parenthetized +SHOW SEQUENCES FROM a -- literals removed +SHOW SEQUENCES FROM _ -- identifiers removed + +parse +SHOW TABLES +---- +SHOW TABLES +SHOW TABLES -- fully parenthetized +SHOW TABLES -- literals removed +SHOW TABLES -- identifiers removed + +parse +SHOW TABLES WITH COMMENT +---- +SHOW TABLES WITH COMMENT +SHOW TABLES WITH COMMENT -- fully parenthetized +SHOW TABLES WITH COMMENT -- literals removed +SHOW TABLES WITH COMMENT -- identifiers removed + +parse +EXPLAIN SHOW TABLES +---- +EXPLAIN SHOW TABLES +EXPLAIN SHOW TABLES -- fully parenthetized +EXPLAIN SHOW TABLES -- literals removed +EXPLAIN SHOW TABLES -- identifiers removed + +parse +SHOW TABLES FROM a +---- +SHOW TABLES FROM a +SHOW TABLES FROM a -- fully parenthetized +SHOW TABLES FROM a -- literals removed +SHOW TABLES FROM _ -- identifiers removed + +parse +SHOW TABLES FROM a WITH COMMENT +---- +SHOW TABLES FROM a WITH COMMENT +SHOW TABLES FROM a WITH COMMENT -- fully parenthetized +SHOW TABLES FROM a WITH COMMENT -- literals removed +SHOW TABLES FROM _ WITH COMMENT -- identifiers removed + +parse +SHOW TABLES FROM a.b +---- +SHOW TABLES FROM a.b +SHOW TABLES FROM a.b -- fully parenthetized +SHOW TABLES FROM a.b -- literals removed +SHOW TABLES FROM _._ -- identifiers removed + +parse +SHOW TABLES FROM a.b WITH COMMENT +---- +SHOW TABLES FROM a.b WITH COMMENT +SHOW TABLES FROM a.b WITH COMMENT -- fully parenthetized +SHOW TABLES FROM a.b WITH COMMENT -- literals removed +SHOW TABLES FROM _._ WITH COMMENT -- identifiers removed + +parse +SHOW COLUMNS FROM a +---- +SHOW COLUMNS FROM a +SHOW COLUMNS FROM a -- fully parenthetized +SHOW COLUMNS FROM a -- literals removed +SHOW COLUMNS FROM _ -- identifiers removed + +parse +EXPLAIN SHOW COLUMNS FROM a +---- +EXPLAIN SHOW COLUMNS FROM a +EXPLAIN SHOW COLUMNS FROM a -- fully parenthetized +EXPLAIN SHOW COLUMNS FROM a -- literals removed +EXPLAIN SHOW COLUMNS FROM _ -- identifiers removed + +parse +SHOW COLUMNS FROM a.b.c +---- +SHOW COLUMNS FROM a.b.c +SHOW COLUMNS FROM a.b.c -- fully parenthetized +SHOW COLUMNS FROM a.b.c -- literals removed +SHOW COLUMNS FROM _._._ -- identifiers removed + +parse +SHOW INDEXES FROM a +---- +SHOW INDEXES FROM a +SHOW INDEXES FROM a -- fully parenthetized +SHOW INDEXES FROM a -- literals removed +SHOW INDEXES FROM _ -- identifiers removed + +parse +EXPLAIN SHOW INDEXES FROM a +---- +EXPLAIN SHOW INDEXES FROM a +EXPLAIN SHOW INDEXES FROM a -- fully parenthetized +EXPLAIN SHOW INDEXES FROM a -- literals removed +EXPLAIN SHOW INDEXES FROM _ -- identifiers removed + +parse +SHOW INDEXES FROM a WITH COMMENT +---- +SHOW INDEXES FROM a WITH COMMENT +SHOW INDEXES FROM a WITH COMMENT -- fully parenthetized +SHOW INDEXES FROM a WITH COMMENT -- literals removed +SHOW INDEXES FROM _ WITH COMMENT -- identifiers removed + +parse +EXPLAIN SHOW INDEXES FROM a WITH COMMENT +---- +EXPLAIN SHOW INDEXES FROM a WITH COMMENT +EXPLAIN SHOW INDEXES FROM a WITH COMMENT -- fully parenthetized +EXPLAIN SHOW INDEXES FROM a WITH COMMENT -- literals removed +EXPLAIN SHOW INDEXES FROM _ WITH COMMENT -- identifiers removed + +parse +SHOW INDEXES FROM a.b.c +---- +SHOW INDEXES FROM a.b.c +SHOW INDEXES FROM a.b.c -- fully parenthetized +SHOW INDEXES FROM a.b.c -- literals removed +SHOW INDEXES FROM _._._ -- identifiers removed + +parse +SHOW INDEXES FROM a.b.c WITH COMMENT +---- +SHOW INDEXES FROM a.b.c WITH COMMENT +SHOW INDEXES FROM a.b.c WITH COMMENT -- fully parenthetized +SHOW INDEXES FROM a.b.c WITH COMMENT -- literals removed +SHOW INDEXES FROM _._._ WITH COMMENT -- identifiers removed + +parse +SHOW INDEXES FROM DATABASE a +---- +SHOW INDEXES FROM DATABASE a +SHOW INDEXES FROM DATABASE a -- fully parenthetized +SHOW INDEXES FROM DATABASE a -- literals removed +SHOW INDEXES FROM DATABASE _ -- identifiers removed + +parse +SHOW INDEXES FROM DATABASE a WITH COMMENT +---- +SHOW INDEXES FROM DATABASE a WITH COMMENT +SHOW INDEXES FROM DATABASE a WITH COMMENT -- fully parenthetized +SHOW INDEXES FROM DATABASE a WITH COMMENT -- literals removed +SHOW INDEXES FROM DATABASE _ WITH COMMENT -- identifiers removed + +parse +SHOW INDEX FROM t +---- +SHOW INDEXES FROM t -- normalized! +SHOW INDEXES FROM t -- fully parenthetized +SHOW INDEXES FROM t -- literals removed +SHOW INDEXES FROM _ -- identifiers removed + + +parse +SHOW KEYS FROM t +---- +SHOW INDEXES FROM t -- normalized! +SHOW INDEXES FROM t -- fully parenthetized +SHOW INDEXES FROM t -- literals removed +SHOW INDEXES FROM _ -- identifiers removed + + +parse +SHOW CONSTRAINTS FROM a +---- +SHOW CONSTRAINTS FROM a +SHOW CONSTRAINTS FROM a -- fully parenthetized +SHOW CONSTRAINTS FROM a -- literals removed +SHOW CONSTRAINTS FROM _ -- identifiers removed + +parse +SHOW CONSTRAINTS FROM a.b.c +---- +SHOW CONSTRAINTS FROM a.b.c +SHOW CONSTRAINTS FROM a.b.c -- fully parenthetized +SHOW CONSTRAINTS FROM a.b.c -- literals removed +SHOW CONSTRAINTS FROM _._._ -- identifiers removed + +parse +EXPLAIN SHOW CONSTRAINTS FROM a.b.c +---- +EXPLAIN SHOW CONSTRAINTS FROM a.b.c +EXPLAIN SHOW CONSTRAINTS FROM a.b.c -- fully parenthetized +EXPLAIN SHOW CONSTRAINTS FROM a.b.c -- literals removed +EXPLAIN SHOW CONSTRAINTS FROM _._._ -- identifiers removed + +parse +SHOW CONSTRAINT FROM t +---- +SHOW CONSTRAINTS FROM t -- normalized! +SHOW CONSTRAINTS FROM t -- fully parenthetized +SHOW CONSTRAINTS FROM t -- literals removed +SHOW CONSTRAINTS FROM _ -- identifiers removed + + +parse +SHOW TABLES FROM a.b; SHOW COLUMNS FROM b +---- +SHOW TABLES FROM a.b; SHOW COLUMNS FROM b +SHOW TABLES FROM a.b; SHOW COLUMNS FROM b -- fully parenthetized +SHOW TABLES FROM a.b; SHOW COLUMNS FROM b -- literals removed +SHOW TABLES FROM _._; SHOW COLUMNS FROM _ -- identifiers removed + +parse +EXPLAIN SHOW TABLES FROM a +---- +EXPLAIN SHOW TABLES FROM a +EXPLAIN SHOW TABLES FROM a -- fully parenthetized +EXPLAIN SHOW TABLES FROM a -- literals removed +EXPLAIN SHOW TABLES FROM _ -- identifiers removed + +parse +SHOW ROLES +---- +SHOW ROLES +SHOW ROLES -- fully parenthetized +SHOW ROLES -- literals removed +SHOW ROLES -- identifiers removed + +parse +EXPLAIN SHOW ROLES +---- +EXPLAIN SHOW ROLES +EXPLAIN SHOW ROLES -- fully parenthetized +EXPLAIN SHOW ROLES -- literals removed +EXPLAIN SHOW ROLES -- identifiers removed + +parse +SHOW USERS +---- +SHOW USERS +SHOW USERS -- fully parenthetized +SHOW USERS -- literals removed +SHOW USERS -- identifiers removed + +parse +EXPLAIN SHOW USERS +---- +EXPLAIN SHOW USERS +EXPLAIN SHOW USERS -- fully parenthetized +EXPLAIN SHOW USERS -- literals removed +EXPLAIN SHOW USERS -- identifiers removed + +parse +SHOW JOBS +---- +SHOW JOBS +SHOW JOBS -- fully parenthetized +SHOW JOBS -- literals removed +SHOW JOBS -- identifiers removed + +parse +EXPLAIN SHOW JOBS +---- +EXPLAIN SHOW JOBS +EXPLAIN SHOW JOBS -- fully parenthetized +EXPLAIN SHOW JOBS -- literals removed +EXPLAIN SHOW JOBS -- identifiers removed + +parse +SHOW AUTOMATIC JOBS +---- +SHOW AUTOMATIC JOBS +SHOW AUTOMATIC JOBS -- fully parenthetized +SHOW AUTOMATIC JOBS -- literals removed +SHOW AUTOMATIC JOBS -- identifiers removed + +parse +EXPLAIN SHOW AUTOMATIC JOBS +---- +EXPLAIN SHOW AUTOMATIC JOBS +EXPLAIN SHOW AUTOMATIC JOBS -- fully parenthetized +EXPLAIN SHOW AUTOMATIC JOBS -- literals removed +EXPLAIN SHOW AUTOMATIC JOBS -- identifiers removed + +parse +SHOW CLUSTER STATEMENTS +---- +SHOW CLUSTER STATEMENTS +SHOW CLUSTER STATEMENTS -- fully parenthetized +SHOW CLUSTER STATEMENTS -- literals removed +SHOW CLUSTER STATEMENTS -- identifiers removed + +parse +EXPLAIN SHOW CLUSTER STATEMENTS +---- +EXPLAIN SHOW CLUSTER STATEMENTS +EXPLAIN SHOW CLUSTER STATEMENTS -- fully parenthetized +EXPLAIN SHOW CLUSTER STATEMENTS -- literals removed +EXPLAIN SHOW CLUSTER STATEMENTS -- identifiers removed + +parse +SHOW STATEMENTS +---- +SHOW CLUSTER STATEMENTS -- normalized! +SHOW CLUSTER STATEMENTS -- fully parenthetized +SHOW CLUSTER STATEMENTS -- literals removed +SHOW CLUSTER STATEMENTS -- identifiers removed + +parse +SHOW QUERIES +---- +SHOW CLUSTER STATEMENTS -- normalized! +SHOW CLUSTER STATEMENTS -- fully parenthetized +SHOW CLUSTER STATEMENTS -- literals removed +SHOW CLUSTER STATEMENTS -- identifiers removed + +parse +SHOW ALL CLUSTER STATEMENTS +---- +SHOW ALL CLUSTER STATEMENTS +SHOW ALL CLUSTER STATEMENTS -- fully parenthetized +SHOW ALL CLUSTER STATEMENTS -- literals removed +SHOW ALL CLUSTER STATEMENTS -- identifiers removed + +parse +EXPLAIN SHOW ALL CLUSTER STATEMENTS +---- +EXPLAIN SHOW ALL CLUSTER STATEMENTS +EXPLAIN SHOW ALL CLUSTER STATEMENTS -- fully parenthetized +EXPLAIN SHOW ALL CLUSTER STATEMENTS -- literals removed +EXPLAIN SHOW ALL CLUSTER STATEMENTS -- identifiers removed + + +parse +SHOW ALL STATEMENTS +---- +SHOW ALL CLUSTER STATEMENTS -- normalized! +SHOW ALL CLUSTER STATEMENTS -- fully parenthetized +SHOW ALL CLUSTER STATEMENTS -- literals removed +SHOW ALL CLUSTER STATEMENTS -- identifiers removed + +parse +SHOW ALL QUERIES +---- +SHOW ALL CLUSTER STATEMENTS -- normalized! +SHOW ALL CLUSTER STATEMENTS -- fully parenthetized +SHOW ALL CLUSTER STATEMENTS -- literals removed +SHOW ALL CLUSTER STATEMENTS -- identifiers removed + +parse +SHOW LOCAL STATEMENTS +---- +SHOW LOCAL STATEMENTS +SHOW LOCAL STATEMENTS -- fully parenthetized +SHOW LOCAL STATEMENTS -- literals removed +SHOW LOCAL STATEMENTS -- identifiers removed + +parse +EXPLAIN SHOW LOCAL STATEMENTS +---- +EXPLAIN SHOW LOCAL STATEMENTS +EXPLAIN SHOW LOCAL STATEMENTS -- fully parenthetized +EXPLAIN SHOW LOCAL STATEMENTS -- literals removed +EXPLAIN SHOW LOCAL STATEMENTS -- identifiers removed + +parse +SHOW ALL LOCAL STATEMENTS +---- +SHOW ALL LOCAL STATEMENTS +SHOW ALL LOCAL STATEMENTS -- fully parenthetized +SHOW ALL LOCAL STATEMENTS -- literals removed +SHOW ALL LOCAL STATEMENTS -- identifiers removed + +parse +EXPLAIN SHOW ALL LOCAL STATEMENTS +---- +EXPLAIN SHOW ALL LOCAL STATEMENTS +EXPLAIN SHOW ALL LOCAL STATEMENTS -- fully parenthetized +EXPLAIN SHOW ALL LOCAL STATEMENTS -- literals removed +EXPLAIN SHOW ALL LOCAL STATEMENTS -- identifiers removed + +parse +SHOW CLUSTER SESSIONS +---- +SHOW CLUSTER SESSIONS +SHOW CLUSTER SESSIONS -- fully parenthetized +SHOW CLUSTER SESSIONS -- literals removed +SHOW CLUSTER SESSIONS -- identifiers removed + +parse +EXPLAIN SHOW CLUSTER SESSIONS +---- +EXPLAIN SHOW CLUSTER SESSIONS +EXPLAIN SHOW CLUSTER SESSIONS -- fully parenthetized +EXPLAIN SHOW CLUSTER SESSIONS -- literals removed +EXPLAIN SHOW CLUSTER SESSIONS -- identifiers removed + +parse +SHOW SESSIONS +---- +SHOW CLUSTER SESSIONS -- normalized! +SHOW CLUSTER SESSIONS -- fully parenthetized +SHOW CLUSTER SESSIONS -- literals removed +SHOW CLUSTER SESSIONS -- identifiers removed + +parse +SHOW ALL CLUSTER SESSIONS +---- +SHOW ALL CLUSTER SESSIONS +SHOW ALL CLUSTER SESSIONS -- fully parenthetized +SHOW ALL CLUSTER SESSIONS -- literals removed +SHOW ALL CLUSTER SESSIONS -- identifiers removed + +parse +EXPLAIN SHOW ALL CLUSTER SESSIONS +---- +EXPLAIN SHOW ALL CLUSTER SESSIONS +EXPLAIN SHOW ALL CLUSTER SESSIONS -- fully parenthetized +EXPLAIN SHOW ALL CLUSTER SESSIONS -- literals removed +EXPLAIN SHOW ALL CLUSTER SESSIONS -- identifiers removed + +parse +SHOW ALL SESSIONS +---- +SHOW ALL CLUSTER SESSIONS -- normalized! +SHOW ALL CLUSTER SESSIONS -- fully parenthetized +SHOW ALL CLUSTER SESSIONS -- literals removed +SHOW ALL CLUSTER SESSIONS -- identifiers removed + +parse +SHOW LOCAL SESSIONS +---- +SHOW LOCAL SESSIONS +SHOW LOCAL SESSIONS -- fully parenthetized +SHOW LOCAL SESSIONS -- literals removed +SHOW LOCAL SESSIONS -- identifiers removed + +parse +EXPLAIN SHOW LOCAL SESSIONS +---- +EXPLAIN SHOW LOCAL SESSIONS +EXPLAIN SHOW LOCAL SESSIONS -- fully parenthetized +EXPLAIN SHOW LOCAL SESSIONS -- literals removed +EXPLAIN SHOW LOCAL SESSIONS -- identifiers removed + +parse +SHOW ALL LOCAL SESSIONS +---- +SHOW ALL LOCAL SESSIONS +SHOW ALL LOCAL SESSIONS -- fully parenthetized +SHOW ALL LOCAL SESSIONS -- literals removed +SHOW ALL LOCAL SESSIONS -- identifiers removed + +parse +EXPLAIN SHOW ALL LOCAL SESSIONS +---- +EXPLAIN SHOW ALL LOCAL SESSIONS +EXPLAIN SHOW ALL LOCAL SESSIONS -- fully parenthetized +EXPLAIN SHOW ALL LOCAL SESSIONS -- literals removed +EXPLAIN SHOW ALL LOCAL SESSIONS -- identifiers removed + +parse +SHOW CLUSTER TRANSACTIONS +---- +SHOW CLUSTER TRANSACTIONS +SHOW CLUSTER TRANSACTIONS -- fully parenthetized +SHOW CLUSTER TRANSACTIONS -- literals removed +SHOW CLUSTER TRANSACTIONS -- identifiers removed + +parse +SHOW TRANSACTIONS +---- +SHOW CLUSTER TRANSACTIONS -- normalized! +SHOW CLUSTER TRANSACTIONS -- fully parenthetized +SHOW CLUSTER TRANSACTIONS -- literals removed +SHOW CLUSTER TRANSACTIONS -- identifiers removed + +parse +SHOW ALL TRANSACTIONS +---- +SHOW ALL CLUSTER TRANSACTIONS -- normalized! +SHOW ALL CLUSTER TRANSACTIONS -- fully parenthetized +SHOW ALL CLUSTER TRANSACTIONS -- literals removed +SHOW ALL CLUSTER TRANSACTIONS -- identifiers removed + +parse +SHOW TRACE FOR SESSION +---- +SHOW TRACE FOR SESSION +SHOW TRACE FOR SESSION -- fully parenthetized +SHOW TRACE FOR SESSION -- literals removed +SHOW TRACE FOR SESSION -- identifiers removed + +parse +EXPLAIN SHOW TRACE FOR SESSION +---- +EXPLAIN SHOW TRACE FOR SESSION +EXPLAIN SHOW TRACE FOR SESSION -- fully parenthetized +EXPLAIN SHOW TRACE FOR SESSION -- literals removed +EXPLAIN SHOW TRACE FOR SESSION -- identifiers removed + +parse +SHOW KV TRACE FOR SESSION +---- +SHOW KV TRACE FOR SESSION +SHOW KV TRACE FOR SESSION -- fully parenthetized +SHOW KV TRACE FOR SESSION -- literals removed +SHOW KV TRACE FOR SESSION -- identifiers removed + +parse +EXPLAIN SHOW KV TRACE FOR SESSION +---- +EXPLAIN SHOW KV TRACE FOR SESSION +EXPLAIN SHOW KV TRACE FOR SESSION -- fully parenthetized +EXPLAIN SHOW KV TRACE FOR SESSION -- literals removed +EXPLAIN SHOW KV TRACE FOR SESSION -- identifiers removed + +parse +SHOW EXPERIMENTAL_REPLICA TRACE FOR SESSION +---- +SHOW EXPERIMENTAL_REPLICA TRACE FOR SESSION +SHOW EXPERIMENTAL_REPLICA TRACE FOR SESSION -- fully parenthetized +SHOW EXPERIMENTAL_REPLICA TRACE FOR SESSION -- literals removed +SHOW EXPERIMENTAL_REPLICA TRACE FOR SESSION -- identifiers removed + +parse +EXPLAIN SHOW EXPERIMENTAL_REPLICA TRACE FOR SESSION +---- +EXPLAIN SHOW EXPERIMENTAL_REPLICA TRACE FOR SESSION +EXPLAIN SHOW EXPERIMENTAL_REPLICA TRACE FOR SESSION -- fully parenthetized +EXPLAIN SHOW EXPERIMENTAL_REPLICA TRACE FOR SESSION -- literals removed +EXPLAIN SHOW EXPERIMENTAL_REPLICA TRACE FOR SESSION -- identifiers removed + +parse +SHOW STATISTICS FOR TABLE t +---- +SHOW STATISTICS FOR TABLE t +SHOW STATISTICS FOR TABLE t -- fully parenthetized +SHOW STATISTICS FOR TABLE t -- literals removed +SHOW STATISTICS FOR TABLE _ -- identifiers removed + +parse +SHOW STATISTICS USING JSON FOR TABLE t +---- +SHOW STATISTICS USING JSON FOR TABLE t +SHOW STATISTICS USING JSON FOR TABLE t -- fully parenthetized +SHOW STATISTICS USING JSON FOR TABLE t -- literals removed +SHOW STATISTICS USING JSON FOR TABLE _ -- identifiers removed + +parse +EXPLAIN SHOW STATISTICS FOR TABLE t +---- +EXPLAIN SHOW STATISTICS FOR TABLE t +EXPLAIN SHOW STATISTICS FOR TABLE t -- fully parenthetized +EXPLAIN SHOW STATISTICS FOR TABLE t -- literals removed +EXPLAIN SHOW STATISTICS FOR TABLE _ -- identifiers removed + +parse +SHOW STATISTICS FOR TABLE d.t +---- +SHOW STATISTICS FOR TABLE d.t +SHOW STATISTICS FOR TABLE d.t -- fully parenthetized +SHOW STATISTICS FOR TABLE d.t -- literals removed +SHOW STATISTICS FOR TABLE _._ -- identifiers removed + +parse +SHOW HISTOGRAM 123 +---- +SHOW HISTOGRAM 123 +SHOW HISTOGRAM 123 -- fully parenthetized +SHOW HISTOGRAM 123 -- literals removed +SHOW HISTOGRAM 123 -- identifiers removed + +parse +EXPLAIN SHOW HISTOGRAM 123 +---- +EXPLAIN SHOW HISTOGRAM 123 +EXPLAIN SHOW HISTOGRAM 123 -- fully parenthetized +EXPLAIN SHOW HISTOGRAM 123 -- literals removed +EXPLAIN SHOW HISTOGRAM 123 -- identifiers removed + +parse +SHOW RANGE FROM TABLE t FOR ROW (1, 2) +---- +SHOW RANGE FROM TABLE t FOR ROW (1, 2) +SHOW RANGE FROM TABLE t FOR ROW ((1), (2)) -- fully parenthetized +SHOW RANGE FROM TABLE t FOR ROW (_, _) -- literals removed +SHOW RANGE FROM TABLE _ FOR ROW (1, 2) -- identifiers removed + +parse +SHOW RANGE FROM TABLE d.t FOR ROW (1, 2) +---- +SHOW RANGE FROM TABLE d.t FOR ROW (1, 2) +SHOW RANGE FROM TABLE d.t FOR ROW ((1), (2)) -- fully parenthetized +SHOW RANGE FROM TABLE d.t FOR ROW (_, _) -- literals removed +SHOW RANGE FROM TABLE _._ FOR ROW (1, 2) -- identifiers removed + +parse +SHOW RANGE FROM INDEX d.t@i FOR ROW (1, 2) +---- +SHOW RANGE FROM INDEX d.t@i FOR ROW (1, 2) +SHOW RANGE FROM INDEX d.t@i FOR ROW ((1), (2)) -- fully parenthetized +SHOW RANGE FROM INDEX d.t@i FOR ROW (_, _) -- literals removed +SHOW RANGE FROM INDEX _._@_ FOR ROW (1, 2) -- identifiers removed + +parse +SHOW RANGE FROM INDEX t@i FOR ROW (1, 2) +---- +SHOW RANGE FROM INDEX t@i FOR ROW (1, 2) +SHOW RANGE FROM INDEX t@i FOR ROW ((1), (2)) -- fully parenthetized +SHOW RANGE FROM INDEX t@i FOR ROW (_, _) -- literals removed +SHOW RANGE FROM INDEX _@_ FOR ROW (1, 2) -- identifiers removed + +parse +SHOW RANGE FROM INDEX i FOR ROW (1, 2) +---- +SHOW RANGE FROM INDEX i FOR ROW (1, 2) +SHOW RANGE FROM INDEX i FOR ROW ((1), (2)) -- fully parenthetized +SHOW RANGE FROM INDEX i FOR ROW (_, _) -- literals removed +SHOW RANGE FROM INDEX _ FOR ROW (1, 2) -- identifiers removed + +parse +SHOW RANGES FROM TABLE d.t +---- +SHOW RANGES FROM TABLE d.t +SHOW RANGES FROM TABLE d.t -- fully parenthetized +SHOW RANGES FROM TABLE d.t -- literals removed +SHOW RANGES FROM TABLE _._ -- identifiers removed + +parse +EXPLAIN SHOW RANGES FROM TABLE d.t +---- +EXPLAIN SHOW RANGES FROM TABLE d.t +EXPLAIN SHOW RANGES FROM TABLE d.t -- fully parenthetized +EXPLAIN SHOW RANGES FROM TABLE d.t -- literals removed +EXPLAIN SHOW RANGES FROM TABLE _._ -- identifiers removed + +parse +SHOW RANGES FROM TABLE t +---- +SHOW RANGES FROM TABLE t +SHOW RANGES FROM TABLE t -- fully parenthetized +SHOW RANGES FROM TABLE t -- literals removed +SHOW RANGES FROM TABLE _ -- identifiers removed + +parse +SHOW RANGES FROM INDEX d.t@i +---- +SHOW RANGES FROM INDEX d.t@i +SHOW RANGES FROM INDEX d.t@i -- fully parenthetized +SHOW RANGES FROM INDEX d.t@i -- literals removed +SHOW RANGES FROM INDEX _._@_ -- identifiers removed + +parse +SHOW RANGES FROM INDEX t@i +---- +SHOW RANGES FROM INDEX t@i +SHOW RANGES FROM INDEX t@i -- fully parenthetized +SHOW RANGES FROM INDEX t@i -- literals removed +SHOW RANGES FROM INDEX _@_ -- identifiers removed + +parse +SHOW RANGES FROM INDEX d.i +---- +SHOW RANGES FROM INDEX d.i +SHOW RANGES FROM INDEX d.i -- fully parenthetized +SHOW RANGES FROM INDEX d.i -- literals removed +SHOW RANGES FROM INDEX _._ -- identifiers removed + +parse +SHOW RANGES FROM INDEX i +---- +SHOW RANGES FROM INDEX i +SHOW RANGES FROM INDEX i -- fully parenthetized +SHOW RANGES FROM INDEX i -- literals removed +SHOW RANGES FROM INDEX _ -- identifiers removed + +parse +SHOW REGIONS +---- +SHOW REGIONS +SHOW REGIONS -- fully parenthetized +SHOW REGIONS -- literals removed +SHOW REGIONS -- identifiers removed + +parse +SHOW REGIONS FROM CLUSTER +---- +SHOW REGIONS FROM CLUSTER +SHOW REGIONS FROM CLUSTER -- fully parenthetized +SHOW REGIONS FROM CLUSTER -- literals removed +SHOW REGIONS FROM CLUSTER -- identifiers removed + +parse +SHOW REGIONS FROM ALL DATABASES +---- +SHOW REGIONS FROM ALL DATABASES +SHOW REGIONS FROM ALL DATABASES -- fully parenthetized +SHOW REGIONS FROM ALL DATABASES -- literals removed +SHOW REGIONS FROM ALL DATABASES -- identifiers removed + +parse +SHOW REGIONS FROM DATABASE +---- +SHOW REGIONS FROM DATABASE +SHOW REGIONS FROM DATABASE -- fully parenthetized +SHOW REGIONS FROM DATABASE -- literals removed +SHOW REGIONS FROM DATABASE -- identifiers removed + +parse +SHOW REGIONS FROM DATABASE d +---- +SHOW REGIONS FROM DATABASE d +SHOW REGIONS FROM DATABASE d -- fully parenthetized +SHOW REGIONS FROM DATABASE d -- literals removed +SHOW REGIONS FROM DATABASE _ -- identifiers removed + +parse +SHOW SURVIVAL GOAL FROM DATABASE +---- +SHOW SURVIVAL GOAL FROM DATABASE +SHOW SURVIVAL GOAL FROM DATABASE -- fully parenthetized +SHOW SURVIVAL GOAL FROM DATABASE -- literals removed +SHOW SURVIVAL GOAL FROM DATABASE -- identifiers removed + +parse +SHOW SURVIVAL GOAL FROM DATABASE d +---- +SHOW SURVIVAL GOAL FROM DATABASE d +SHOW SURVIVAL GOAL FROM DATABASE d -- fully parenthetized +SHOW SURVIVAL GOAL FROM DATABASE d -- literals removed +SHOW SURVIVAL GOAL FROM DATABASE _ -- identifiers removed + +parse +SHOW EXPERIMENTAL_FINGERPRINTS FROM TABLE d.t +---- +SHOW EXPERIMENTAL_FINGERPRINTS FROM TABLE d.t +SHOW EXPERIMENTAL_FINGERPRINTS FROM TABLE d.t -- fully parenthetized +SHOW EXPERIMENTAL_FINGERPRINTS FROM TABLE d.t -- literals removed +SHOW EXPERIMENTAL_FINGERPRINTS FROM TABLE _._ -- identifiers removed + +parse +SHOW ZONE CONFIGURATIONS +---- +SHOW ZONE CONFIGURATIONS +SHOW ZONE CONFIGURATIONS -- fully parenthetized +SHOW ZONE CONFIGURATIONS -- literals removed +SHOW ZONE CONFIGURATIONS -- identifiers removed + +parse +EXPLAIN SHOW ZONE CONFIGURATIONS +---- +EXPLAIN SHOW ZONE CONFIGURATIONS +EXPLAIN SHOW ZONE CONFIGURATIONS -- fully parenthetized +EXPLAIN SHOW ZONE CONFIGURATIONS -- literals removed +EXPLAIN SHOW ZONE CONFIGURATIONS -- identifiers removed + + +parse +SHOW ALL ZONE CONFIGURATIONS +---- +SHOW ZONE CONFIGURATIONS -- normalized! +SHOW ZONE CONFIGURATIONS -- fully parenthetized +SHOW ZONE CONFIGURATIONS -- literals removed +SHOW ZONE CONFIGURATIONS -- identifiers removed + + +parse +SHOW ZONE CONFIGURATION FROM RANGE default +---- +SHOW ZONE CONFIGURATION FROM RANGE default +SHOW ZONE CONFIGURATION FROM RANGE default -- fully parenthetized +SHOW ZONE CONFIGURATION FROM RANGE default -- literals removed +SHOW ZONE CONFIGURATION FROM RANGE _ -- identifiers removed + +parse +SHOW ZONE CONFIGURATION FOR RANGE foo +---- +SHOW ZONE CONFIGURATION FROM RANGE foo -- normalized! +SHOW ZONE CONFIGURATION FROM RANGE foo -- fully parenthetized +SHOW ZONE CONFIGURATION FROM RANGE foo -- literals removed +SHOW ZONE CONFIGURATION FROM RANGE _ -- identifiers removed + + +parse +SHOW ZONE CONFIGURATION FROM RANGE meta +---- +SHOW ZONE CONFIGURATION FROM RANGE meta +SHOW ZONE CONFIGURATION FROM RANGE meta -- fully parenthetized +SHOW ZONE CONFIGURATION FROM RANGE meta -- literals removed +SHOW ZONE CONFIGURATION FROM RANGE _ -- identifiers removed + +parse +SHOW ZONE CONFIGURATION FROM DATABASE db +---- +SHOW ZONE CONFIGURATION FROM DATABASE db +SHOW ZONE CONFIGURATION FROM DATABASE db -- fully parenthetized +SHOW ZONE CONFIGURATION FROM DATABASE db -- literals removed +SHOW ZONE CONFIGURATION FROM DATABASE _ -- identifiers removed + +parse +SHOW ZONE CONFIGURATION FOR DATABASE foo +---- +SHOW ZONE CONFIGURATION FROM DATABASE foo -- normalized! +SHOW ZONE CONFIGURATION FROM DATABASE foo -- fully parenthetized +SHOW ZONE CONFIGURATION FROM DATABASE foo -- literals removed +SHOW ZONE CONFIGURATION FROM DATABASE _ -- identifiers removed + +parse +SHOW ZONE CONFIGURATION FROM TABLE db.t +---- +SHOW ZONE CONFIGURATION FROM TABLE db.t +SHOW ZONE CONFIGURATION FROM TABLE db.t -- fully parenthetized +SHOW ZONE CONFIGURATION FROM TABLE db.t -- literals removed +SHOW ZONE CONFIGURATION FROM TABLE _._ -- identifiers removed + +parse +SHOW ZONE CONFIGURATION FOR TABLE foo +---- +SHOW ZONE CONFIGURATION FROM TABLE foo -- normalized! +SHOW ZONE CONFIGURATION FROM TABLE foo -- fully parenthetized +SHOW ZONE CONFIGURATION FROM TABLE foo -- literals removed +SHOW ZONE CONFIGURATION FROM TABLE _ -- identifiers removed + +parse +SHOW ZONE CONFIGURATION FROM TABLE db.schema.t +---- +SHOW ZONE CONFIGURATION FROM TABLE db.schema.t +SHOW ZONE CONFIGURATION FROM TABLE db.schema.t -- fully parenthetized +SHOW ZONE CONFIGURATION FROM TABLE db.schema.t -- literals removed +SHOW ZONE CONFIGURATION FROM TABLE _._._ -- identifiers removed + +parse +SHOW ZONE CONFIGURATION FROM PARTITION p OF TABLE db.t +---- +SHOW ZONE CONFIGURATION FROM PARTITION p OF TABLE db.t +SHOW ZONE CONFIGURATION FROM PARTITION p OF TABLE db.t -- fully parenthetized +SHOW ZONE CONFIGURATION FROM PARTITION p OF TABLE db.t -- literals removed +SHOW ZONE CONFIGURATION FROM PARTITION _ OF TABLE _._ -- identifiers removed + +parse +SHOW ZONE CONFIGURATION FROM TABLE t PARTITION foo +---- +SHOW ZONE CONFIGURATION FROM PARTITION foo OF TABLE t -- normalized! +SHOW ZONE CONFIGURATION FROM PARTITION foo OF TABLE t -- fully parenthetized +SHOW ZONE CONFIGURATION FROM PARTITION foo OF TABLE t -- literals removed +SHOW ZONE CONFIGURATION FROM PARTITION _ OF TABLE _ -- identifiers removed + +parse +SHOW ZONE CONFIGURATION FOR TABLE foo PARTITION bar +---- +SHOW ZONE CONFIGURATION FROM PARTITION bar OF TABLE foo -- normalized! +SHOW ZONE CONFIGURATION FROM PARTITION bar OF TABLE foo -- fully parenthetized +SHOW ZONE CONFIGURATION FROM PARTITION bar OF TABLE foo -- literals removed +SHOW ZONE CONFIGURATION FROM PARTITION _ OF TABLE _ -- identifiers removed + +parse +SHOW ZONE CONFIGURATION FOR PARTITION foo OF TABLE bar +---- +SHOW ZONE CONFIGURATION FROM PARTITION foo OF TABLE bar -- normalized! +SHOW ZONE CONFIGURATION FROM PARTITION foo OF TABLE bar -- fully parenthetized +SHOW ZONE CONFIGURATION FROM PARTITION foo OF TABLE bar -- literals removed +SHOW ZONE CONFIGURATION FROM PARTITION _ OF TABLE _ -- identifiers removed + +parse +SHOW ZONE CONFIGURATION FROM INDEX t@idx PARTITION foo +---- +SHOW ZONE CONFIGURATION FROM PARTITION foo OF INDEX t@idx -- normalized! +SHOW ZONE CONFIGURATION FROM PARTITION foo OF INDEX t@idx -- fully parenthetized +SHOW ZONE CONFIGURATION FROM PARTITION foo OF INDEX t@idx -- literals removed +SHOW ZONE CONFIGURATION FROM PARTITION _ OF INDEX _@_ -- identifiers removed + + +parse +SHOW ZONE CONFIGURATION FROM TABLE t +---- +SHOW ZONE CONFIGURATION FROM TABLE t +SHOW ZONE CONFIGURATION FROM TABLE t -- fully parenthetized +SHOW ZONE CONFIGURATION FROM TABLE t -- literals removed +SHOW ZONE CONFIGURATION FROM TABLE _ -- identifiers removed + +parse +SHOW ZONE CONFIGURATION FROM PARTITION p OF TABLE t +---- +SHOW ZONE CONFIGURATION FROM PARTITION p OF TABLE t +SHOW ZONE CONFIGURATION FROM PARTITION p OF TABLE t -- fully parenthetized +SHOW ZONE CONFIGURATION FROM PARTITION p OF TABLE t -- literals removed +SHOW ZONE CONFIGURATION FROM PARTITION _ OF TABLE _ -- identifiers removed + +parse +SHOW ZONE CONFIGURATION FROM INDEX db.t@i +---- +SHOW ZONE CONFIGURATION FROM INDEX db.t@i +SHOW ZONE CONFIGURATION FROM INDEX db.t@i -- fully parenthetized +SHOW ZONE CONFIGURATION FROM INDEX db.t@i -- literals removed +SHOW ZONE CONFIGURATION FROM INDEX _._@_ -- identifiers removed + +parse +SHOW ZONE CONFIGURATION FROM INDEX t@i +---- +SHOW ZONE CONFIGURATION FROM INDEX t@i +SHOW ZONE CONFIGURATION FROM INDEX t@i -- fully parenthetized +SHOW ZONE CONFIGURATION FROM INDEX t@i -- literals removed +SHOW ZONE CONFIGURATION FROM INDEX _@_ -- identifiers removed + +parse +SHOW ZONE CONFIGURATION FROM INDEX i +---- +SHOW ZONE CONFIGURATION FROM INDEX i +SHOW ZONE CONFIGURATION FROM INDEX i -- fully parenthetized +SHOW ZONE CONFIGURATION FROM INDEX i -- literals removed +SHOW ZONE CONFIGURATION FROM INDEX _ -- identifiers removed + +parse +SHOW ZONE CONFIGURATION FOR INDEX foo +---- +SHOW ZONE CONFIGURATION FROM INDEX foo -- normalized! +SHOW ZONE CONFIGURATION FROM INDEX foo -- fully parenthetized +SHOW ZONE CONFIGURATION FROM INDEX foo -- literals removed +SHOW ZONE CONFIGURATION FROM INDEX _ -- identifiers removed + +parse +SHOW ZONE CONFIGURATION FOR INDEX foo PARTITION bar +---- +SHOW ZONE CONFIGURATION FROM PARTITION bar OF INDEX foo -- normalized! +SHOW ZONE CONFIGURATION FROM PARTITION bar OF INDEX foo -- fully parenthetized +SHOW ZONE CONFIGURATION FROM PARTITION bar OF INDEX foo -- literals removed +SHOW ZONE CONFIGURATION FROM PARTITION _ OF INDEX _ -- identifiers removed + +parse +SHOW ZONE CONFIGURATION FOR PARTITION foo OF INDEX bar +---- +SHOW ZONE CONFIGURATION FROM PARTITION foo OF INDEX bar -- normalized! +SHOW ZONE CONFIGURATION FROM PARTITION foo OF INDEX bar -- fully parenthetized +SHOW ZONE CONFIGURATION FROM PARTITION foo OF INDEX bar -- literals removed +SHOW ZONE CONFIGURATION FROM PARTITION _ OF INDEX _ -- identifiers removed + + +## Tables are the default, but can also be specified with +## GRANT x ON TABLE y. However, the stringer does not output TABLE. + +parse +SHOW GRANTS +---- +SHOW GRANTS +SHOW GRANTS -- fully parenthetized +SHOW GRANTS -- literals removed +SHOW GRANTS -- identifiers removed + +parse +EXPLAIN SHOW GRANTS +---- +EXPLAIN SHOW GRANTS +EXPLAIN SHOW GRANTS -- fully parenthetized +EXPLAIN SHOW GRANTS -- literals removed +EXPLAIN SHOW GRANTS -- identifiers removed + +parse +SHOW GRANTS ON role +---- +SHOW GRANTS ON ROLE -- normalized! +SHOW GRANTS ON ROLE -- fully parenthetized +SHOW GRANTS ON ROLE -- literals removed +SHOW GRANTS ON ROLE -- identifiers removed + +parse +SHOW GRANTS ON role foo +---- +SHOW GRANTS ON ROLE foo -- normalized! +SHOW GRANTS ON ROLE foo -- fully parenthetized +SHOW GRANTS ON ROLE foo -- literals removed +SHOW GRANTS ON ROLE _ -- identifiers removed + +parse +SHOW GRANTS ON role foo, bar +---- +SHOW GRANTS ON ROLE foo, bar -- normalized! +SHOW GRANTS ON ROLE foo, bar -- fully parenthetized +SHOW GRANTS ON ROLE foo, bar -- literals removed +SHOW GRANTS ON ROLE _, _ -- identifiers removed + +parse +SHOW GRANTS ON TABLE foo +---- +SHOW GRANTS ON TABLE foo +SHOW GRANTS ON TABLE (foo) -- fully parenthetized +SHOW GRANTS ON TABLE foo -- literals removed +SHOW GRANTS ON TABLE _ -- identifiers removed + +parse +SHOW GRANTS ON "role" +---- +SHOW GRANTS ON TABLE role -- normalized! +SHOW GRANTS ON TABLE (role) -- fully parenthetized +SHOW GRANTS ON TABLE role -- literals removed +SHOW GRANTS ON TABLE _ -- identifiers removed + + +parse +SHOW GRANTS ON role, foo +---- +SHOW GRANTS ON TABLE role, foo -- normalized! +SHOW GRANTS ON TABLE (role), (foo) -- fully parenthetized +SHOW GRANTS ON TABLE role, foo -- literals removed +SHOW GRANTS ON TABLE _, _ -- identifiers removed + +parse +SHOW GRANTS ON foo +---- +SHOW GRANTS ON TABLE foo -- normalized! +SHOW GRANTS ON TABLE (foo) -- fully parenthetized +SHOW GRANTS ON TABLE foo -- literals removed +SHOW GRANTS ON TABLE _ -- identifiers removed + +parse +SHOW GRANTS ON foo, db.foo +---- +SHOW GRANTS ON TABLE foo, db.foo -- normalized! +SHOW GRANTS ON TABLE (foo), (db.foo) -- fully parenthetized +SHOW GRANTS ON TABLE foo, db.foo -- literals removed +SHOW GRANTS ON TABLE _, _._ -- identifiers removed + +parse +SHOW GRANTS ON "role", foo +---- +SHOW GRANTS ON TABLE role, foo -- normalized! +SHOW GRANTS ON TABLE (role), (foo) -- fully parenthetized +SHOW GRANTS ON TABLE role, foo -- literals removed +SHOW GRANTS ON TABLE _, _ -- identifiers removed + +parse +SHOW GRANTS ON "role".foo +---- +SHOW GRANTS ON TABLE role.foo -- normalized! +SHOW GRANTS ON TABLE (role.foo) -- fully parenthetized +SHOW GRANTS ON TABLE role.foo -- literals removed +SHOW GRANTS ON TABLE _._ -- identifiers removed + +parse +SHOW GRANTS ON role.foo +---- +SHOW GRANTS ON TABLE role.foo -- normalized! +SHOW GRANTS ON TABLE (role.foo) -- fully parenthetized +SHOW GRANTS ON TABLE role.foo -- literals removed +SHOW GRANTS ON TABLE _._ -- identifiers removed + +parse +SHOW GRANTS ON role.* +---- +SHOW GRANTS ON TABLE role.* -- normalized! +SHOW GRANTS ON TABLE (role.*) -- fully parenthetized +SHOW GRANTS ON TABLE role.* -- literals removed +SHOW GRANTS ON TABLE _.* -- identifiers removed + +parse +SHOW GRANTS ON SCHEMA foo +---- +SHOW GRANTS ON SCHEMA foo +SHOW GRANTS ON SCHEMA foo -- fully parenthetized +SHOW GRANTS ON SCHEMA foo -- literals removed +SHOW GRANTS ON SCHEMA _ -- identifiers removed + +parse +SHOW GRANTS ON SCHEMA foo.bar +---- +SHOW GRANTS ON SCHEMA foo.bar +SHOW GRANTS ON SCHEMA foo.bar -- fully parenthetized +SHOW GRANTS ON SCHEMA foo.bar -- literals removed +SHOW GRANTS ON SCHEMA _._ -- identifiers removed + +parse +SHOW GRANTS ON SCHEMA foo, bar +---- +SHOW GRANTS ON SCHEMA foo, bar +SHOW GRANTS ON SCHEMA foo, bar -- fully parenthetized +SHOW GRANTS ON SCHEMA foo, bar -- literals removed +SHOW GRANTS ON SCHEMA _, _ -- identifiers removed + +parse +SHOW GRANTS ON SCHEMA foo.bar, bar.baz +---- +SHOW GRANTS ON SCHEMA foo.bar, bar.baz +SHOW GRANTS ON SCHEMA foo.bar, bar.baz -- fully parenthetized +SHOW GRANTS ON SCHEMA foo.bar, bar.baz -- literals removed +SHOW GRANTS ON SCHEMA _._, _._ -- identifiers removed + +parse +SHOW GRANTS ON TYPE typ1 +---- +SHOW GRANTS ON TYPE typ1 +SHOW GRANTS ON TYPE typ1 -- fully parenthetized +SHOW GRANTS ON TYPE typ1 -- literals removed +SHOW GRANTS ON TYPE _ -- identifiers removed + +parse +SHOW GRANTS ON TYPE typ1, schema2.typ2, db.schema.typ +---- +SHOW GRANTS ON TYPE typ1, schema2.typ2, db.schema.typ +SHOW GRANTS ON TYPE typ1, schema2.typ2, db.schema.typ -- fully parenthetized +SHOW GRANTS ON TYPE typ1, schema2.typ2, db.schema.typ -- literals removed +SHOW GRANTS ON TYPE _, _._, _._._ -- identifiers removed + +parse +SHOW GRANTS ON TABLE foo, db.foo +---- +SHOW GRANTS ON TABLE foo, db.foo +SHOW GRANTS ON TABLE (foo), (db.foo) -- fully parenthetized +SHOW GRANTS ON TABLE foo, db.foo -- literals removed +SHOW GRANTS ON TABLE _, _._ -- identifiers removed + +parse +SHOW GRANTS ON TYPE foo +---- +SHOW GRANTS ON TYPE foo +SHOW GRANTS ON TYPE foo -- fully parenthetized +SHOW GRANTS ON TYPE foo -- literals removed +SHOW GRANTS ON TYPE _ -- identifiers removed + +parse +SHOW GRANTS ON TYPE foo, bar +---- +SHOW GRANTS ON TYPE foo, bar +SHOW GRANTS ON TYPE foo, bar -- fully parenthetized +SHOW GRANTS ON TYPE foo, bar -- literals removed +SHOW GRANTS ON TYPE _, _ -- identifiers removed + +parse +SHOW GRANTS ON TYPE foo, bar FOR baz +---- +SHOW GRANTS ON TYPE foo, bar FOR baz +SHOW GRANTS ON TYPE foo, bar FOR baz -- fully parenthetized +SHOW GRANTS ON TYPE foo, bar FOR baz -- literals removed +SHOW GRANTS ON TYPE _, _ FOR _ -- identifiers removed + +parse +SHOW GRANTS ON DATABASE foo, bar +---- +SHOW GRANTS ON DATABASE foo, bar +SHOW GRANTS ON DATABASE foo, bar -- fully parenthetized +SHOW GRANTS ON DATABASE foo, bar -- literals removed +SHOW GRANTS ON DATABASE _, _ -- identifiers removed + +parse +SHOW GRANTS ON DATABASE foo FOR bar +---- +SHOW GRANTS ON DATABASE foo FOR bar +SHOW GRANTS ON DATABASE foo FOR bar -- fully parenthetized +SHOW GRANTS ON DATABASE foo FOR bar -- literals removed +SHOW GRANTS ON DATABASE _ FOR _ -- identifiers removed + +parse +SHOW GRANTS FOR bar, baz +---- +SHOW GRANTS FOR bar, baz +SHOW GRANTS FOR bar, baz -- fully parenthetized +SHOW GRANTS FOR bar, baz -- literals removed +SHOW GRANTS FOR _, _ -- identifiers removed + +parse +SHOW GRANTS ON ROLE +---- +SHOW GRANTS ON ROLE +SHOW GRANTS ON ROLE -- fully parenthetized +SHOW GRANTS ON ROLE -- literals removed +SHOW GRANTS ON ROLE -- identifiers removed + +parse +SHOW GRANTS ON ROLE foo +---- +SHOW GRANTS ON ROLE foo +SHOW GRANTS ON ROLE foo -- fully parenthetized +SHOW GRANTS ON ROLE foo -- literals removed +SHOW GRANTS ON ROLE _ -- identifiers removed + +parse +SHOW GRANTS ON ROLE foo, bar +---- +SHOW GRANTS ON ROLE foo, bar +SHOW GRANTS ON ROLE foo, bar -- fully parenthetized +SHOW GRANTS ON ROLE foo, bar -- literals removed +SHOW GRANTS ON ROLE _, _ -- identifiers removed + +parse +SHOW GRANTS ON ROLE foo FOR bar +---- +SHOW GRANTS ON ROLE foo FOR bar +SHOW GRANTS ON ROLE foo FOR bar -- fully parenthetized +SHOW GRANTS ON ROLE foo FOR bar -- literals removed +SHOW GRANTS ON ROLE _ FOR _ -- identifiers removed + +parse +SHOW GRANTS ON ROLE FOR bar, baz +---- +SHOW GRANTS ON ROLE FOR bar, baz +SHOW GRANTS ON ROLE FOR bar, baz -- fully parenthetized +SHOW GRANTS ON ROLE FOR bar, baz -- literals removed +SHOW GRANTS ON ROLE FOR _, _ -- identifiers removed + +parse +SHOW TRANSACTION STATUS +---- +SHOW TRANSACTION STATUS +SHOW TRANSACTION STATUS -- fully parenthetized +SHOW TRANSACTION STATUS -- literals removed +SHOW TRANSACTION STATUS -- identifiers removed + +parse +EXPLAIN SHOW TRANSACTION STATUS +---- +EXPLAIN SHOW TRANSACTION STATUS +EXPLAIN SHOW TRANSACTION STATUS -- fully parenthetized +EXPLAIN SHOW TRANSACTION STATUS -- literals removed +EXPLAIN SHOW TRANSACTION STATUS -- identifiers removed + +parse +SHOW TRANSACTION ISOLATION LEVEL +---- +SHOW transaction_isolation -- normalized! +SHOW transaction_isolation -- fully parenthetized +SHOW transaction_isolation -- literals removed +SHOW transaction_isolation -- identifiers removed + +parse +SHOW TRANSACTION PRIORITY +---- +SHOW transaction_priority -- normalized! +SHOW transaction_priority -- fully parenthetized +SHOW transaction_priority -- literals removed +SHOW transaction_priority -- identifiers removed + +parse +SHOW SAVEPOINT STATUS +---- +SHOW SAVEPOINT STATUS +SHOW SAVEPOINT STATUS -- fully parenthetized +SHOW SAVEPOINT STATUS -- literals removed +SHOW SAVEPOINT STATUS -- identifiers removed + +parse +EXPLAIN SHOW SAVEPOINT STATUS +---- +EXPLAIN SHOW SAVEPOINT STATUS +EXPLAIN SHOW SAVEPOINT STATUS -- fully parenthetized +EXPLAIN SHOW SAVEPOINT STATUS -- literals removed +EXPLAIN SHOW SAVEPOINT STATUS -- identifiers removed + + + +parse +SHOW LAST QUERY STATISTICS +---- +SHOW LAST QUERY STATISTICS +SHOW LAST QUERY STATISTICS -- fully parenthetized +SHOW LAST QUERY STATISTICS -- literals removed +SHOW LAST QUERY STATISTICS -- identifiers removed + +parse +SHOW SYNTAX 'select 1' +---- +SHOW SYNTAX 'select 1' +SHOW SYNTAX 'select 1' -- fully parenthetized +SHOW SYNTAX _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +SHOW SYNTAX _ -- identifiers removed + +parse +EXPLAIN SHOW SYNTAX 'select 1' +---- +EXPLAIN SHOW SYNTAX 'select 1' +EXPLAIN SHOW SYNTAX 'select 1' -- fully parenthetized +EXPLAIN SHOW SYNTAX _ -- literals removed +REPARSE WITHOUT LITERALS FAILS: at or near "_": syntax error +EXPLAIN SHOW SYNTAX _ -- identifiers removed + +parse +SHOW CREATE TABLE t +---- +SHOW CREATE t -- normalized! +SHOW CREATE t -- fully parenthetized +SHOW CREATE t -- literals removed +SHOW CREATE _ -- identifiers removed + +parse +SHOW CREATE VIEW t +---- +SHOW CREATE t -- normalized! +SHOW CREATE t -- fully parenthetized +SHOW CREATE t -- literals removed +SHOW CREATE _ -- identifiers removed + +parse +SHOW CREATE SEQUENCE t +---- +SHOW CREATE t -- normalized! +SHOW CREATE t -- fully parenthetized +SHOW CREATE t -- literals removed +SHOW CREATE _ -- identifiers removed + +parse +SHOW NAMES +---- +SHOW client_encoding -- normalized! +SHOW client_encoding -- fully parenthetized +SHOW client_encoding -- literals removed +SHOW client_encoding -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/source_stmt b/pkg/sql/parser/testdata/parse/source_stmt new file mode 100644 index 000000000000..a6ce2d198c72 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/source_stmt @@ -0,0 +1,15 @@ +parse +SELECT * FROM [EXPLAIN SELECT 1] +---- +SELECT * FROM [EXPLAIN SELECT 1] +SELECT (*) FROM [EXPLAIN SELECT (1)] -- fully parenthetized +SELECT * FROM [EXPLAIN SELECT _] -- literals removed +SELECT * FROM [EXPLAIN SELECT 1] -- identifiers removed + +parse +SELECT * FROM [SHOW TRANSACTION STATUS] +---- +SELECT * FROM [SHOW TRANSACTION STATUS] +SELECT (*) FROM [SHOW TRANSACTION STATUS] -- fully parenthetized +SELECT * FROM [SHOW TRANSACTION STATUS] -- literals removed +SELECT * FROM [SHOW TRANSACTION STATUS] -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/table_by_id b/pkg/sql/parser/testdata/parse/table_by_id new file mode 100644 index 000000000000..1ca6f8f4a222 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/table_by_id @@ -0,0 +1,120 @@ +parse +SELECT * FROM [123 AS t] +---- +SELECT * FROM [123 AS t] +SELECT (*) FROM [123 AS t] -- fully parenthetized +SELECT * FROM [123 AS t] -- literals removed +SELECT * FROM [123 AS _] -- identifiers removed + +parse +SELECT * FROM [123(1, 2, 3) AS t] +---- +SELECT * FROM [123(1, 2, 3) AS t] +SELECT (*) FROM [123(1, 2, 3) AS t] -- fully parenthetized +SELECT * FROM [123(1, 2, 3) AS t] -- literals removed +SELECT * FROM [123(1, 2, 3) AS _] -- identifiers removed + +parse +SELECT * FROM [123() AS t] +---- +SELECT * FROM [123() AS t] +SELECT (*) FROM [123() AS t] -- fully parenthetized +SELECT * FROM [123() AS t] -- literals removed +SELECT * FROM [123() AS _] -- identifiers removed + +parse +SELECT * FROM t@[123] +---- +SELECT * FROM t@[123] +SELECT (*) FROM t@[123] -- fully parenthetized +SELECT * FROM t@[123] -- literals removed +SELECT * FROM _@[123] -- identifiers removed + +parse +SELECT * FROM [123 AS t]@[456] +---- +SELECT * FROM [123 AS t]@[456] +SELECT (*) FROM [123 AS t]@[456] -- fully parenthetized +SELECT * FROM [123 AS t]@[456] -- literals removed +SELECT * FROM [123 AS _]@[456] -- identifiers removed + +parse +SELECT 'a' FROM t@{FORCE_INDEX=[123]} +---- +SELECT 'a' FROM t@[123] -- normalized! +SELECT ('a') FROM t@[123] -- fully parenthetized +SELECT _ FROM t@[123] -- literals removed +SELECT 'a' FROM _@[123] -- identifiers removed + +parse +SELECT 'a' FROM [123 AS t]@{FORCE_INDEX=[456]} +---- +SELECT 'a' FROM [123 AS t]@[456] -- normalized! +SELECT ('a') FROM [123 AS t]@[456] -- fully parenthetized +SELECT _ FROM [123 AS t]@[456] -- literals removed +SELECT 'a' FROM [123 AS _]@[456] -- identifiers removed + + +parse +INSERT INTO [123 AS t] VALUES (1) +---- +INSERT INTO [123 AS t] VALUES (1) +INSERT INTO [123 AS t] VALUES ((1)) -- fully parenthetized +INSERT INTO [123 AS t] VALUES (_) -- literals removed +INSERT INTO [123 AS _] VALUES (1) -- identifiers removed + +parse +INSERT INTO [123(1, 2) AS t] VALUES (1, 2) +---- +INSERT INTO [123(1, 2) AS t] VALUES (1, 2) +INSERT INTO [123(1, 2) AS t] VALUES ((1), (2)) -- fully parenthetized +INSERT INTO [123(1, 2) AS t] VALUES (_, _) -- literals removed +INSERT INTO [123(1, 2) AS _] VALUES (1, 2) -- identifiers removed + +parse +INSERT INTO [123 AS t](col1, col2) VALUES (1, 2) +---- +INSERT INTO [123 AS t](col1, col2) VALUES (1, 2) +INSERT INTO [123 AS t](col1, col2) VALUES ((1), (2)) -- fully parenthetized +INSERT INTO [123 AS t](col1, col2) VALUES (_, _) -- literals removed +INSERT INTO [123 AS _](_, _) VALUES (1, 2) -- identifiers removed + +parse +UPSERT INTO [123 AS t] VALUES (1) +---- +UPSERT INTO [123 AS t] VALUES (1) +UPSERT INTO [123 AS t] VALUES ((1)) -- fully parenthetized +UPSERT INTO [123 AS t] VALUES (_) -- literals removed +UPSERT INTO [123 AS _] VALUES (1) -- identifiers removed + +parse +UPDATE [123 AS t] SET b = 3 +---- +UPDATE [123 AS t] SET b = 3 +UPDATE [123 AS t] SET b = (3) -- fully parenthetized +UPDATE [123 AS t] SET b = _ -- literals removed +UPDATE [123 AS _] SET _ = 3 -- identifiers removed + +parse +UPDATE [123 AS t]@idx SET b = 3 +---- +UPDATE [123 AS t]@idx SET b = 3 +UPDATE [123 AS t]@idx SET b = (3) -- fully parenthetized +UPDATE [123 AS t]@idx SET b = _ -- literals removed +UPDATE [123 AS _]@_ SET _ = 3 -- identifiers removed + +parse +DELETE FROM [123 AS t] +---- +DELETE FROM [123 AS t] +DELETE FROM [123 AS t] -- fully parenthetized +DELETE FROM [123 AS t] -- literals removed +DELETE FROM [123 AS _] -- identifiers removed + +parse +DELETE FROM [123 AS t]@idx +---- +DELETE FROM [123 AS t]@idx +DELETE FROM [123 AS t]@idx -- fully parenthetized +DELETE FROM [123 AS t]@idx -- literals removed +DELETE FROM [123 AS _]@_ -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/table_stmt b/pkg/sql/parser/testdata/parse/table_stmt new file mode 100644 index 000000000000..ceac9e0f937b --- /dev/null +++ b/pkg/sql/parser/testdata/parse/table_stmt @@ -0,0 +1,34 @@ +## TABLE is shorthand for: SELECT * FROM a; +## used e.g. in CREATE VIEW v AS TABLE t + +parse +TABLE a +---- +TABLE a +TABLE a -- fully parenthetized +TABLE a -- literals removed +TABLE _ -- identifiers removed + +parse +EXPLAIN TABLE a +---- +EXPLAIN TABLE a +EXPLAIN TABLE a -- fully parenthetized +EXPLAIN TABLE a -- literals removed +EXPLAIN TABLE _ -- identifiers removed + +parse +TABLE [123 AS a] +---- +TABLE [123 AS a] +TABLE [123 AS a] -- fully parenthetized +TABLE [123 AS a] -- literals removed +TABLE [123 AS _] -- identifiers removed + +parse +VALUES ("") -- nb: double quote is an identifier, not a string +---- +VALUES ("") -- normalized! +VALUES (("")) -- fully parenthetized +VALUES ("") -- literals removed +VALUES (_) -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/truncate b/pkg/sql/parser/testdata/parse/truncate new file mode 100644 index 000000000000..5f561c97ff02 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/truncate @@ -0,0 +1,31 @@ +parse +TRUNCATE TABLE a +---- +TRUNCATE TABLE a +TRUNCATE TABLE a -- fully parenthetized +TRUNCATE TABLE a -- literals removed +TRUNCATE TABLE _ -- identifiers removed + +parse +EXPLAIN TRUNCATE TABLE a +---- +EXPLAIN TRUNCATE TABLE a +EXPLAIN TRUNCATE TABLE a -- fully parenthetized +EXPLAIN TRUNCATE TABLE a -- literals removed +EXPLAIN TRUNCATE TABLE _ -- identifiers removed + +parse +TRUNCATE TABLE a, b.c +---- +TRUNCATE TABLE a, b.c +TRUNCATE TABLE a, b.c -- fully parenthetized +TRUNCATE TABLE a, b.c -- literals removed +TRUNCATE TABLE _, _._ -- identifiers removed + +parse +TRUNCATE TABLE a CASCADE +---- +TRUNCATE TABLE a CASCADE +TRUNCATE TABLE a CASCADE -- fully parenthetized +TRUNCATE TABLE a CASCADE -- literals removed +TRUNCATE TABLE _ CASCADE -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/update b/pkg/sql/parser/testdata/parse/update new file mode 100644 index 000000000000..18e095f3e3d6 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/update @@ -0,0 +1,201 @@ +parse +UPDATE a SET b = 3 +---- +UPDATE a SET b = 3 +UPDATE a SET b = (3) -- fully parenthetized +UPDATE a SET b = _ -- literals removed +UPDATE _ SET _ = 3 -- identifiers removed + +parse +EXPLAIN UPDATE a SET b = 3 +---- +EXPLAIN UPDATE a SET b = 3 +EXPLAIN UPDATE a SET b = (3) -- fully parenthetized +EXPLAIN UPDATE a SET b = _ -- literals removed +EXPLAIN UPDATE _ SET _ = 3 -- identifiers removed + +parse +UPDATE a.b SET b = 3 +---- +UPDATE a.b SET b = 3 +UPDATE a.b SET b = (3) -- fully parenthetized +UPDATE a.b SET b = _ -- literals removed +UPDATE _._ SET _ = 3 -- identifiers removed + +parse +UPDATE a.b@c SET b = 3 +---- +UPDATE a.b@c SET b = 3 +UPDATE a.b@c SET b = (3) -- fully parenthetized +UPDATE a.b@c SET b = _ -- literals removed +UPDATE _._@_ SET _ = 3 -- identifiers removed + +parse +UPDATE a SET b = 3, c = DEFAULT +---- +UPDATE a SET b = 3, c = DEFAULT +UPDATE a SET b = (3), c = (DEFAULT) -- fully parenthetized +UPDATE a SET b = _, c = DEFAULT -- literals removed +UPDATE _ SET _ = 3, _ = DEFAULT -- identifiers removed + +parse +UPDATE a SET b = 3, c = DEFAULT FROM b +---- +UPDATE a SET b = 3, c = DEFAULT FROM b +UPDATE a SET b = (3), c = (DEFAULT) FROM b -- fully parenthetized +UPDATE a SET b = _, c = DEFAULT FROM b -- literals removed +UPDATE _ SET _ = 3, _ = DEFAULT FROM _ -- identifiers removed + +parse +UPDATE a SET b = 3, c = DEFAULT FROM a AS other +---- +UPDATE a SET b = 3, c = DEFAULT FROM a AS other +UPDATE a SET b = (3), c = (DEFAULT) FROM a AS other -- fully parenthetized +UPDATE a SET b = _, c = DEFAULT FROM a AS other -- literals removed +UPDATE _ SET _ = 3, _ = DEFAULT FROM _ AS _ -- identifiers removed + +parse +UPDATE a SET b = 3, c = DEFAULT FROM a AS other, b +---- +UPDATE a SET b = 3, c = DEFAULT FROM a AS other, b +UPDATE a SET b = (3), c = (DEFAULT) FROM a AS other, b -- fully parenthetized +UPDATE a SET b = _, c = DEFAULT FROM a AS other, b -- literals removed +UPDATE _ SET _ = 3, _ = DEFAULT FROM _ AS _, _ -- identifiers removed + +parse +UPDATE a SET b = 3 + 4 +---- +UPDATE a SET b = 3 + 4 +UPDATE a SET b = ((3) + (4)) -- fully parenthetized +UPDATE a SET b = _ + _ -- literals removed +UPDATE _ SET _ = 3 + 4 -- identifiers removed + +parse +UPDATE a SET (b, c) = (3, DEFAULT) +---- +UPDATE a SET (b, c) = (3, DEFAULT) +UPDATE a SET (b, c) = (((3), (DEFAULT))) -- fully parenthetized +UPDATE a SET (b, c) = (_, DEFAULT) -- literals removed +UPDATE _ SET (_, _) = (3, DEFAULT) -- identifiers removed + +parse +UPDATE a SET (b, c) = (SELECT 3, 4) +---- +UPDATE a SET (b, c) = (SELECT 3, 4) +UPDATE a SET (b, c) = ((SELECT (3), (4))) -- fully parenthetized +UPDATE a SET (b, c) = (SELECT _, _) -- literals removed +UPDATE _ SET (_, _) = (SELECT 3, 4) -- identifiers removed + +parse +UPDATE a SET b = 3 WHERE a = b +---- +UPDATE a SET b = 3 WHERE a = b +UPDATE a SET b = (3) WHERE ((a) = (b)) -- fully parenthetized +UPDATE a SET b = _ WHERE a = b -- literals removed +UPDATE _ SET _ = 3 WHERE _ = _ -- identifiers removed + +parse +UPDATE a SET b = 3 WHERE a = b LIMIT c +---- +UPDATE a SET b = 3 WHERE a = b LIMIT c +UPDATE a SET b = (3) WHERE ((a) = (b)) LIMIT (c) -- fully parenthetized +UPDATE a SET b = _ WHERE a = b LIMIT c -- literals removed +UPDATE _ SET _ = 3 WHERE _ = _ LIMIT _ -- identifiers removed + +parse +UPDATE a SET b = 3 WHERE a = b ORDER BY c +---- +UPDATE a SET b = 3 WHERE a = b ORDER BY c +UPDATE a SET b = (3) WHERE ((a) = (b)) ORDER BY (c) -- fully parenthetized +UPDATE a SET b = _ WHERE a = b ORDER BY c -- literals removed +UPDATE _ SET _ = 3 WHERE _ = _ ORDER BY _ -- identifiers removed + +parse +UPDATE a SET b = 3 WHERE a = b ORDER BY c LIMIT d +---- +UPDATE a SET b = 3 WHERE a = b ORDER BY c LIMIT d +UPDATE a SET b = (3) WHERE ((a) = (b)) ORDER BY (c) LIMIT (d) -- fully parenthetized +UPDATE a SET b = _ WHERE a = b ORDER BY c LIMIT d -- literals removed +UPDATE _ SET _ = 3 WHERE _ = _ ORDER BY _ LIMIT _ -- identifiers removed + +parse +UPDATE a SET b = 3 WHERE a = b RETURNING a +---- +UPDATE a SET b = 3 WHERE a = b RETURNING a +UPDATE a SET b = (3) WHERE ((a) = (b)) RETURNING (a) -- fully parenthetized +UPDATE a SET b = _ WHERE a = b RETURNING a -- literals removed +UPDATE _ SET _ = 3 WHERE _ = _ RETURNING _ -- identifiers removed + +parse +UPDATE a SET b = 3 WHERE a = b RETURNING 1, 2 +---- +UPDATE a SET b = 3 WHERE a = b RETURNING 1, 2 +UPDATE a SET b = (3) WHERE ((a) = (b)) RETURNING (1), (2) -- fully parenthetized +UPDATE a SET b = _ WHERE a = b RETURNING _, _ -- literals removed +UPDATE _ SET _ = 3 WHERE _ = _ RETURNING 1, 2 -- identifiers removed + +parse +UPDATE a SET b = 3 WHERE a = b RETURNING a, a + b +---- +UPDATE a SET b = 3 WHERE a = b RETURNING a, a + b +UPDATE a SET b = (3) WHERE ((a) = (b)) RETURNING (a), ((a) + (b)) -- fully parenthetized +UPDATE a SET b = _ WHERE a = b RETURNING a, a + b -- literals removed +UPDATE _ SET _ = 3 WHERE _ = _ RETURNING _, _ + _ -- identifiers removed + +parse +UPDATE a SET b = 3 WHERE a = b RETURNING NOTHING +---- +UPDATE a SET b = 3 WHERE a = b RETURNING NOTHING +UPDATE a SET b = (3) WHERE ((a) = (b)) RETURNING NOTHING -- fully parenthetized +UPDATE a SET b = _ WHERE a = b RETURNING NOTHING -- literals removed +UPDATE _ SET _ = 3 WHERE _ = _ RETURNING NOTHING -- identifiers removed + +parse +UPDATE a SET b = 3 WHERE a = b ORDER BY c LIMIT d RETURNING e +---- +UPDATE a SET b = 3 WHERE a = b ORDER BY c LIMIT d RETURNING e +UPDATE a SET b = (3) WHERE ((a) = (b)) ORDER BY (c) LIMIT (d) RETURNING (e) -- fully parenthetized +UPDATE a SET b = _ WHERE a = b ORDER BY c LIMIT d RETURNING e -- literals removed +UPDATE _ SET _ = 3 WHERE _ = _ ORDER BY _ LIMIT _ RETURNING _ -- identifiers removed + +parse +UPDATE a SET b = 3 FROM other WHERE a = b ORDER BY c LIMIT d RETURNING e +---- +UPDATE a SET b = 3 FROM other WHERE a = b ORDER BY c LIMIT d RETURNING e +UPDATE a SET b = (3) FROM other WHERE ((a) = (b)) ORDER BY (c) LIMIT (d) RETURNING (e) -- fully parenthetized +UPDATE a SET b = _ FROM other WHERE a = b ORDER BY c LIMIT d RETURNING e -- literals removed +UPDATE _ SET _ = 3 FROM _ WHERE _ = _ ORDER BY _ LIMIT _ RETURNING _ -- identifiers removed + +# regression test: "0" once mistakenly lost its quotes + +parse +UPDATE t AS "0" SET k = '' +---- +UPDATE t AS "0" SET k = '' +UPDATE t AS "0" SET k = ('') -- fully parenthetized +UPDATE t AS "0" SET k = _ -- literals removed +UPDATE _ AS _ SET _ = '' -- identifiers removed + +parse +UPDATE ONLY a SET b = 3 +---- +UPDATE a SET b = 3 -- normalized! +UPDATE a SET b = (3) -- fully parenthetized +UPDATE a SET b = _ -- literals removed +UPDATE _ SET _ = 3 -- identifiers removed + +parse +UPDATE ONLY a * SET b = 3 +---- +UPDATE a SET b = 3 -- normalized! +UPDATE a SET b = (3) -- fully parenthetized +UPDATE a SET b = _ -- literals removed +UPDATE _ SET _ = 3 -- identifiers removed + +parse +UPDATE a * SET b = 3 +---- +UPDATE a SET b = 3 -- normalized! +UPDATE a SET b = (3) -- fully parenthetized +UPDATE a SET b = _ -- literals removed +UPDATE _ SET _ = 3 -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/upsert b/pkg/sql/parser/testdata/parse/upsert new file mode 100644 index 000000000000..4b935de89928 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/upsert @@ -0,0 +1,223 @@ +parse +UPSERT INTO a VALUES (1) +---- +UPSERT INTO a VALUES (1) +UPSERT INTO a VALUES ((1)) -- fully parenthetized +UPSERT INTO a VALUES (_) -- literals removed +UPSERT INTO _ VALUES (1) -- identifiers removed + +parse +EXPLAIN UPSERT INTO a VALUES (1) +---- +EXPLAIN UPSERT INTO a VALUES (1) +EXPLAIN UPSERT INTO a VALUES ((1)) -- fully parenthetized +EXPLAIN UPSERT INTO a VALUES (_) -- literals removed +EXPLAIN UPSERT INTO _ VALUES (1) -- identifiers removed + +parse +UPSERT INTO a.b VALUES (1) +---- +UPSERT INTO a.b VALUES (1) +UPSERT INTO a.b VALUES ((1)) -- fully parenthetized +UPSERT INTO a.b VALUES (_) -- literals removed +UPSERT INTO _._ VALUES (1) -- identifiers removed + +parse +UPSERT INTO a VALUES (1, 2) +---- +UPSERT INTO a VALUES (1, 2) +UPSERT INTO a VALUES ((1), (2)) -- fully parenthetized +UPSERT INTO a VALUES (_, _) -- literals removed +UPSERT INTO _ VALUES (1, 2) -- identifiers removed + +parse +UPSERT INTO a VALUES (1, DEFAULT) +---- +UPSERT INTO a VALUES (1, DEFAULT) +UPSERT INTO a VALUES ((1), (DEFAULT)) -- fully parenthetized +UPSERT INTO a VALUES (_, DEFAULT) -- literals removed +UPSERT INTO _ VALUES (1, DEFAULT) -- identifiers removed + +parse +UPSERT INTO a VALUES (1, 2), (3, 4) +---- +UPSERT INTO a VALUES (1, 2), (3, 4) +UPSERT INTO a VALUES ((1), (2)), ((3), (4)) -- fully parenthetized +UPSERT INTO a VALUES (_, _), (__more1__) -- literals removed +UPSERT INTO _ VALUES (1, 2), (3, 4) -- identifiers removed + +parse +UPSERT INTO a VALUES (a + 1, 2 * 3) +---- +UPSERT INTO a VALUES (a + 1, 2 * 3) +UPSERT INTO a VALUES (((a) + (1)), ((2) * (3))) -- fully parenthetized +UPSERT INTO a VALUES (a + _, _ * _) -- literals removed +UPSERT INTO _ VALUES (_ + 1, 2 * 3) -- identifiers removed + +parse +UPSERT INTO a(a, b) VALUES (1, 2) +---- +UPSERT INTO a(a, b) VALUES (1, 2) +UPSERT INTO a(a, b) VALUES ((1), (2)) -- fully parenthetized +UPSERT INTO a(a, b) VALUES (_, _) -- literals removed +UPSERT INTO _(_, _) VALUES (1, 2) -- identifiers removed + +parse +UPSERT INTO a SELECT b, c FROM d +---- +UPSERT INTO a SELECT b, c FROM d +UPSERT INTO a SELECT (b), (c) FROM d -- fully parenthetized +UPSERT INTO a SELECT b, c FROM d -- literals removed +UPSERT INTO _ SELECT _, _ FROM _ -- identifiers removed + +parse +UPSERT INTO a DEFAULT VALUES +---- +UPSERT INTO a DEFAULT VALUES +UPSERT INTO a DEFAULT VALUES -- fully parenthetized +UPSERT INTO a DEFAULT VALUES -- literals removed +UPSERT INTO _ DEFAULT VALUES -- identifiers removed + +parse +UPSERT INTO a DEFAULT VALUES RETURNING a, b +---- +UPSERT INTO a DEFAULT VALUES RETURNING a, b +UPSERT INTO a DEFAULT VALUES RETURNING (a), (b) -- fully parenthetized +UPSERT INTO a DEFAULT VALUES RETURNING a, b -- literals removed +UPSERT INTO _ DEFAULT VALUES RETURNING _, _ -- identifiers removed + +parse +UPSERT INTO a DEFAULT VALUES RETURNING 1, 2 +---- +UPSERT INTO a DEFAULT VALUES RETURNING 1, 2 +UPSERT INTO a DEFAULT VALUES RETURNING (1), (2) -- fully parenthetized +UPSERT INTO a DEFAULT VALUES RETURNING _, _ -- literals removed +UPSERT INTO _ DEFAULT VALUES RETURNING 1, 2 -- identifiers removed + +parse +UPSERT INTO a DEFAULT VALUES RETURNING a + b +---- +UPSERT INTO a DEFAULT VALUES RETURNING a + b +UPSERT INTO a DEFAULT VALUES RETURNING ((a) + (b)) -- fully parenthetized +UPSERT INTO a DEFAULT VALUES RETURNING a + b -- literals removed +UPSERT INTO _ DEFAULT VALUES RETURNING _ + _ -- identifiers removed + +parse +UPSERT INTO a DEFAULT VALUES RETURNING NOTHING +---- +UPSERT INTO a DEFAULT VALUES RETURNING NOTHING +UPSERT INTO a DEFAULT VALUES RETURNING NOTHING -- fully parenthetized +UPSERT INTO a DEFAULT VALUES RETURNING NOTHING -- literals removed +UPSERT INTO _ DEFAULT VALUES RETURNING NOTHING -- identifiers removed + +parse +INSERT INTO a VALUES (1) ON CONFLICT DO NOTHING +---- +INSERT INTO a VALUES (1) ON CONFLICT DO NOTHING +INSERT INTO a VALUES ((1)) ON CONFLICT DO NOTHING -- fully parenthetized +INSERT INTO a VALUES (_) ON CONFLICT DO NOTHING -- literals removed +INSERT INTO _ VALUES (1) ON CONFLICT DO NOTHING -- identifiers removed + +parse +INSERT INTO a VALUES (1) ON CONFLICT (a) DO NOTHING +---- +INSERT INTO a VALUES (1) ON CONFLICT (a) DO NOTHING +INSERT INTO a VALUES ((1)) ON CONFLICT (a) DO NOTHING -- fully parenthetized +INSERT INTO a VALUES (_) ON CONFLICT (a) DO NOTHING -- literals removed +INSERT INTO _ VALUES (1) ON CONFLICT (_) DO NOTHING -- identifiers removed + +parse +INSERT INTO a VALUES (1) ON CONFLICT (a) WHERE b > 0 DO NOTHING +---- +INSERT INTO a VALUES (1) ON CONFLICT (a) WHERE b > 0 DO NOTHING +INSERT INTO a VALUES ((1)) ON CONFLICT (a) WHERE ((b) > (0)) DO NOTHING -- fully parenthetized +INSERT INTO a VALUES (_) ON CONFLICT (a) WHERE b > _ DO NOTHING -- literals removed +INSERT INTO _ VALUES (1) ON CONFLICT (_) WHERE _ > 0 DO NOTHING -- identifiers removed + +parse +INSERT INTO a VALUES (1) ON CONFLICT (a) DO UPDATE SET a = 1 +---- +INSERT INTO a VALUES (1) ON CONFLICT (a) DO UPDATE SET a = 1 +INSERT INTO a VALUES ((1)) ON CONFLICT (a) DO UPDATE SET a = (1) -- fully parenthetized +INSERT INTO a VALUES (_) ON CONFLICT (a) DO UPDATE SET a = _ -- literals removed +INSERT INTO _ VALUES (1) ON CONFLICT (_) DO UPDATE SET _ = 1 -- identifiers removed + +parse +INSERT INTO a VALUES (1) ON CONFLICT (a) WHERE b > 0 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) WHERE ((b) > (0)) DO UPDATE SET a = (1) -- fully parenthetized +INSERT INTO a VALUES (_) ON CONFLICT (a) WHERE b > _ DO UPDATE SET a = _ -- literals removed +INSERT INTO _ VALUES (1) ON CONFLICT (_) WHERE _ > 0 DO UPDATE SET _ = 1 -- identifiers removed + +parse +INSERT INTO a VALUES (1) ON CONFLICT (a, b) 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, b) DO UPDATE SET a = (1) -- fully parenthetized +INSERT INTO a VALUES (_) ON CONFLICT (a, b) DO UPDATE SET a = _ -- literals removed +INSERT INTO _ VALUES (1) ON CONFLICT (_, _) DO UPDATE SET _ = 1 -- identifiers removed + +parse +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, b = excluded.a +INSERT INTO a VALUES ((1)) ON CONFLICT (a) DO UPDATE SET a = (1), b = (excluded.a) -- fully parenthetized +INSERT INTO a VALUES (_) ON CONFLICT (a) DO UPDATE SET a = _, b = excluded.a -- literals removed +INSERT INTO _ VALUES (1) ON CONFLICT (_) DO UPDATE SET _ = 1, _ = _._ -- identifiers removed + +parse +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 = 1 WHERE b > 2 +INSERT INTO a VALUES ((1)) ON CONFLICT (a) DO UPDATE SET a = (1) WHERE ((b) > (2)) -- fully parenthetized +INSERT INTO a VALUES (_) ON CONFLICT (a) DO UPDATE SET a = _ WHERE b > _ -- literals removed +INSERT INTO _ VALUES (1) ON CONFLICT (_) DO UPDATE SET _ = 1 WHERE _ > 2 -- identifiers removed + +parse +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 = DEFAULT +INSERT INTO a VALUES ((1)) ON CONFLICT (a) DO UPDATE SET a = (DEFAULT) -- fully parenthetized +INSERT INTO a VALUES (_) ON CONFLICT (a) DO UPDATE SET a = DEFAULT -- literals removed +INSERT INTO _ VALUES (1) ON CONFLICT (_) DO UPDATE SET _ = DEFAULT -- identifiers removed + +parse +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) +INSERT INTO a VALUES ((1)) ON CONFLICT (a) DO UPDATE SET (a, b) = ((SELECT (1), (2))) -- fully parenthetized +INSERT INTO a VALUES (_) ON CONFLICT (a) DO UPDATE SET (a, b) = (SELECT _, _) -- literals removed +INSERT INTO _ VALUES (1) ON CONFLICT (_) DO UPDATE SET (_, _) = (SELECT 1, 2) -- identifiers removed + +parse +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 a, b +INSERT INTO a VALUES ((1)) ON CONFLICT (a) DO UPDATE SET (a, b) = ((SELECT (1), (2))) RETURNING (a), (b) -- fully parenthetized +INSERT INTO a VALUES (_) ON CONFLICT (a) DO UPDATE SET (a, b) = (SELECT _, _) RETURNING a, b -- literals removed +INSERT INTO _ VALUES (1) ON CONFLICT (_) DO UPDATE SET (_, _) = (SELECT 1, 2) RETURNING _, _ -- identifiers removed + +parse +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 1, 2 +INSERT INTO a VALUES ((1)) ON CONFLICT (a) DO UPDATE SET (a, b) = ((SELECT (1), (2))) RETURNING (1), (2) -- fully parenthetized +INSERT INTO a VALUES (_) ON CONFLICT (a) DO UPDATE SET (a, b) = (SELECT _, _) RETURNING _, _ -- literals removed +INSERT INTO _ VALUES (1) ON CONFLICT (_) DO UPDATE SET (_, _) = (SELECT 1, 2) RETURNING 1, 2 -- identifiers removed + +parse +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 a + b +INSERT INTO a VALUES ((1)) ON CONFLICT (a) DO UPDATE SET (a, b) = ((SELECT (1), (2))) RETURNING ((a) + (b)) -- fully parenthetized +INSERT INTO a VALUES (_) ON CONFLICT (a) DO UPDATE SET (a, b) = (SELECT _, _) RETURNING a + b -- literals removed +INSERT INTO _ VALUES (1) ON CONFLICT (_) DO UPDATE SET (_, _) = (SELECT 1, 2) RETURNING _ + _ -- identifiers removed + +parse +INSERT INTO a VALUES (1) ON CONFLICT (a) DO UPDATE SET (a, b) = (SELECT 1, 2) RETURNING NOTHING +---- +INSERT INTO a VALUES (1) ON CONFLICT (a) DO UPDATE SET (a, b) = (SELECT 1, 2) RETURNING NOTHING +INSERT INTO a VALUES ((1)) ON CONFLICT (a) DO UPDATE SET (a, b) = ((SELECT (1), (2))) RETURNING NOTHING -- fully parenthetized +INSERT INTO a VALUES (_) ON CONFLICT (a) DO UPDATE SET (a, b) = (SELECT _, _) RETURNING NOTHING -- literals removed +INSERT INTO _ VALUES (1) ON CONFLICT (_) DO UPDATE SET (_, _) = (SELECT 1, 2) RETURNING NOTHING -- identifiers removed diff --git a/pkg/sql/parser/testdata/parse/user_defined_types b/pkg/sql/parser/testdata/parse/user_defined_types new file mode 100644 index 000000000000..d506ccb596a2 --- /dev/null +++ b/pkg/sql/parser/testdata/parse/user_defined_types @@ -0,0 +1,156 @@ +parse +CREATE TABLE t (x special.type) +---- +CREATE TABLE t (x special.type) +CREATE TABLE t (x special.type) -- fully parenthetized +CREATE TABLE t (x special.type) -- literals removed +CREATE TABLE _ (_ special.type) -- identifiers removed + +parse +CREATE TABLE t (x int4.type) +---- +CREATE TABLE t (x int4.type) +CREATE TABLE t (x int4.type) -- fully parenthetized +CREATE TABLE t (x int4.type) -- literals removed +CREATE TABLE _ (_ int4.type) -- identifiers removed + +parse +CREATE TABLE t (x notatype) +---- +CREATE TABLE t (x notatype) +CREATE TABLE t (x notatype) -- fully parenthetized +CREATE TABLE t (x notatype) -- literals removed +CREATE TABLE _ (_ notatype) -- identifiers removed + +parse +SELECT 1 IS OF (my.type, int4.type) +---- +SELECT 1 IS OF (my.type, int4.type) +SELECT ((1) IS OF (my.type, int4.type)) -- fully parenthetized +SELECT _ IS OF (my.type, int4.type) -- literals removed +SELECT 1 IS OF (_._, _._) -- identifiers removed + +parse +SELECT my.type '' +---- +SELECT my.type '' +SELECT (my.type ('')) -- fully parenthetized +SELECT my.type _ -- literals removed +SELECT my.type AS _ -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT _._ '' -- identifiers removed + +parse +SELECT int4.type '' +---- +SELECT int4.type '' +SELECT (int4.type ('')) -- fully parenthetized +SELECT int4.type _ -- literals removed +SELECT int4.type AS _ -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT _._ '' -- identifiers removed + +parse +SELECT foo '' +---- +SELECT foo '' +SELECT (foo ('')) -- fully parenthetized +SELECT foo _ -- literals removed +SELECT foo AS _ -- UNEXPECTED REPARSED AST WITHOUT LITERALS +SELECT _ '' -- identifiers removed + +parse +SELECT CAST(1.2 + 2.3 AS notatype) +---- +SELECT CAST(1.2 + 2.3 AS notatype) +SELECT (CAST(((1.2) + (2.3)) AS notatype)) -- fully parenthetized +SELECT CAST(_ + _ AS notatype) -- literals removed +SELECT CAST(1.2 + 2.3 AS _) -- identifiers removed + +parse +SELECT ANNOTATE_TYPE(1.2 + 2.3, notatype) +---- +SELECT ANNOTATE_TYPE(1.2 + 2.3, notatype) +SELECT (ANNOTATE_TYPE(((1.2) + (2.3)), notatype)) -- fully parenthetized +SELECT ANNOTATE_TYPE(_ + _, notatype) -- literals removed +SELECT ANNOTATE_TYPE(1.2 + 2.3, _) -- identifiers removed + +parse +SELECT 'f'::blah +---- +SELECT 'f'::blah +SELECT (('f')::blah) -- fully parenthetized +SELECT _::blah -- literals removed +SELECT 'f'::_ -- identifiers removed + +## Test various cases of qualified and not statically known types. + +parse +SELECT 1::notatype +---- +SELECT 1::notatype +SELECT ((1)::notatype) -- fully parenthetized +SELECT _::notatype -- literals removed +SELECT 1::_ -- identifiers removed + +parse +SELECT 1::schem.typ +---- +SELECT 1::schem.typ +SELECT ((1)::schem.typ) -- fully parenthetized +SELECT _::schem.typ -- literals removed +SELECT 1::_._ -- identifiers removed + +parse +SELECT 1::int4.typ +---- +SELECT 1::int4.typ +SELECT ((1)::int4.typ) -- fully parenthetized +SELECT _::int4.typ -- literals removed +SELECT 1::_._ -- identifiers removed + +parse +SELECT 1::db.schem.typ +---- +SELECT 1::db.schem.typ +SELECT ((1)::db.schem.typ) -- fully parenthetized +SELECT _::db.schem.typ -- literals removed +SELECT 1::_._._ -- identifiers removed + +parse +SELECT 1::db.int4.typ[] +---- +SELECT 1::db.int4.typ[] +SELECT ((1)::db.int4.typ[]) -- fully parenthetized +SELECT _::db.int4.typ[] -- literals removed +SELECT 1::_._._[] -- identifiers removed + +parse +SELECT 1::db.int4.typ array [1] +---- +SELECT 1::db.int4.typ[] -- normalized! +SELECT ((1)::db.int4.typ[]) -- fully parenthetized +SELECT _::db.int4.typ[] -- literals removed +SELECT 1::_._._[] -- identifiers removed + +parse +SELECT 1::int4.typ array [1] +---- +SELECT 1::int4.typ[] -- normalized! +SELECT ((1)::int4.typ[]) -- fully parenthetized +SELECT _::int4.typ[] -- literals removed +SELECT 1::_._[] -- identifiers removed + +parse +SELECT 1::db.int4.typ array +---- +SELECT 1::db.int4.typ[] -- normalized! +SELECT ((1)::db.int4.typ[]) -- fully parenthetized +SELECT _::db.int4.typ[] -- literals removed +SELECT 1::_._._[] -- identifiers removed + +parse +CREATE TABLE t (x int4.type array [1]) +---- +CREATE TABLE t (x int4.type[]) -- normalized! +CREATE TABLE t (x int4.type[]) -- fully parenthetized +CREATE TABLE t (x int4.type[]) -- literals removed +CREATE TABLE _ (_ int4.type[]) -- identifiers removed diff --git a/pkg/sql/sem/tree/alter_table.go b/pkg/sql/sem/tree/alter_table.go index e186b2623792..716255bbf80c 100644 --- a/pkg/sql/sem/tree/alter_table.go +++ b/pkg/sql/sem/tree/alter_table.go @@ -564,9 +564,9 @@ func (node *AlterTableLocality) Format(ctx *FmtCtx) { if node.IfExists { ctx.WriteString("IF EXISTS ") } - node.Name.Format(ctx) + ctx.FormatNode(node.Name) ctx.WriteString(" SET ") - node.Locality.Format(ctx) + ctx.FormatNode(node.Locality) } // AlterTableSetSchema represents an ALTER TABLE SET SCHEMA command. @@ -595,7 +595,7 @@ func (node *AlterTableSetSchema) Format(ctx *FmtCtx) { if node.IfExists { ctx.WriteString("IF EXISTS ") } - node.Name.Format(ctx) + ctx.FormatNode(node.Name) ctx.WriteString(" SET SCHEMA ") ctx.FormatNode(&node.Schema) } @@ -645,7 +645,7 @@ func (node *AlterTableOwner) Format(ctx *FmtCtx) { if node.IfExists { ctx.WriteString("IF EXISTS ") } - node.Name.Format(ctx) + ctx.FormatNode(node.Name) ctx.WriteString(" OWNER TO ") ctx.FormatUsername(node.Owner) } diff --git a/pkg/sql/sem/tree/backup.go b/pkg/sql/sem/tree/backup.go index 2406d6a3c7f2..d7cd4efb9fb7 100644 --- a/pkg/sql/sem/tree/backup.go +++ b/pkg/sql/sem/tree/backup.go @@ -212,8 +212,12 @@ func (o *BackupOptions) Format(ctx *FmtCtx) { if o.EncryptionPassphrase != nil { maybeAddSep() - ctx.WriteString("encryption_passphrase=") - o.EncryptionPassphrase.Format(ctx) + ctx.WriteString("encryption_passphrase = ") + if ctx.flags.HasFlags(FmtShowPasswords) { + ctx.FormatNode(o.EncryptionPassphrase) + } else { + ctx.WriteString(PasswordSubstitution) + } } if o.Detached { @@ -223,8 +227,8 @@ func (o *BackupOptions) Format(ctx *FmtCtx) { if o.EncryptionKMSURI != nil { maybeAddSep() - ctx.WriteString("kms=") - o.EncryptionKMSURI.Format(ctx) + ctx.WriteString("kms = ") + ctx.FormatNode(&o.EncryptionKMSURI) } } @@ -281,20 +285,20 @@ func (o *RestoreOptions) Format(ctx *FmtCtx) { } if o.EncryptionPassphrase != nil { addSep = true - ctx.WriteString("encryption_passphrase=") - o.EncryptionPassphrase.Format(ctx) + ctx.WriteString("encryption_passphrase = ") + ctx.FormatNode(o.EncryptionPassphrase) } if o.DecryptionKMSURI != nil { maybeAddSep() - ctx.WriteString("kms=") - o.DecryptionKMSURI.Format(ctx) + ctx.WriteString("kms = ") + ctx.FormatNode(&o.DecryptionKMSURI) } if o.IntoDB != nil { maybeAddSep() - ctx.WriteString("into_db=") - ctx.formatNodeOrHideConstants(o.IntoDB) + ctx.WriteString("into_db = ") + ctx.FormatNode(o.IntoDB) } if o.SkipMissingFKs { diff --git a/pkg/sql/sem/tree/col_name.go b/pkg/sql/sem/tree/col_name.go index b93802726533..2c2e52b2817a 100644 --- a/pkg/sql/sem/tree/col_name.go +++ b/pkg/sql/sem/tree/col_name.go @@ -155,7 +155,7 @@ func ComputeColNameInternal(sp sessiondata.SearchPath, target Expr) (int, string return 2, "iferror", nil case *ColumnAccessExpr: - return 2, e.ColName, nil + return 2, string(e.ColName), nil case *DBool: // PostgreSQL implements the "true" and "false" literals diff --git a/pkg/sql/sem/tree/comment_on_column.go b/pkg/sql/sem/tree/comment_on_column.go index 92f0663aa97f..25f9acd4729b 100644 --- a/pkg/sql/sem/tree/comment_on_column.go +++ b/pkg/sql/sem/tree/comment_on_column.go @@ -24,7 +24,13 @@ func (n *CommentOnColumn) Format(ctx *FmtCtx) { ctx.FormatNode(n.ColumnItem) ctx.WriteString(" IS ") if n.Comment != nil { - lex.EncodeSQLStringWithFlags(&ctx.Buffer, *n.Comment, ctx.flags.EncodeFlags()) + // TODO(knz): Replace all this with ctx.FormatNode + // when COMMENT supports expressions. + if ctx.flags.HasFlags(FmtHideConstants) { + ctx.WriteByte('_') + } else { + lex.EncodeSQLStringWithFlags(&ctx.Buffer, *n.Comment, ctx.flags.EncodeFlags()) + } } else { ctx.WriteString("NULL") } diff --git a/pkg/sql/sem/tree/comment_on_database.go b/pkg/sql/sem/tree/comment_on_database.go index 9ece86dee6f9..32baade67bc2 100644 --- a/pkg/sql/sem/tree/comment_on_database.go +++ b/pkg/sql/sem/tree/comment_on_database.go @@ -24,7 +24,13 @@ func (n *CommentOnDatabase) Format(ctx *FmtCtx) { ctx.FormatNode(&n.Name) ctx.WriteString(" IS ") if n.Comment != nil { - lex.EncodeSQLStringWithFlags(&ctx.Buffer, *n.Comment, ctx.flags.EncodeFlags()) + // TODO(knz): Replace all this with ctx.FormatNode + // when COMMENT supports expressions. + if ctx.flags.HasFlags(FmtHideConstants) { + ctx.WriteByte('_') + } else { + lex.EncodeSQLStringWithFlags(&ctx.Buffer, *n.Comment, ctx.flags.EncodeFlags()) + } } else { ctx.WriteString("NULL") } diff --git a/pkg/sql/sem/tree/comment_on_index.go b/pkg/sql/sem/tree/comment_on_index.go index f24cd84cafa5..83ea4b404774 100644 --- a/pkg/sql/sem/tree/comment_on_index.go +++ b/pkg/sql/sem/tree/comment_on_index.go @@ -24,7 +24,13 @@ func (n *CommentOnIndex) Format(ctx *FmtCtx) { ctx.FormatNode(&n.Index) ctx.WriteString(" IS ") if n.Comment != nil { - lex.EncodeSQLStringWithFlags(&ctx.Buffer, *n.Comment, ctx.flags.EncodeFlags()) + // TODO(knz): Replace all this with ctx.FormatNode + // when COMMENT supports expressions. + if ctx.flags.HasFlags(FmtHideConstants) { + ctx.WriteByte('_') + } else { + lex.EncodeSQLStringWithFlags(&ctx.Buffer, *n.Comment, ctx.flags.EncodeFlags()) + } } else { ctx.WriteString("NULL") } diff --git a/pkg/sql/sem/tree/comment_on_table.go b/pkg/sql/sem/tree/comment_on_table.go index ef6555febdbd..755deb2d92db 100644 --- a/pkg/sql/sem/tree/comment_on_table.go +++ b/pkg/sql/sem/tree/comment_on_table.go @@ -24,7 +24,13 @@ func (n *CommentOnTable) Format(ctx *FmtCtx) { ctx.FormatNode(n.Table) ctx.WriteString(" IS ") if n.Comment != nil { - lex.EncodeSQLStringWithFlags(&ctx.Buffer, *n.Comment, ctx.flags.EncodeFlags()) + // TODO(knz): Replace all this with ctx.FormatNode + // when COMMENT supports expressions. + if ctx.flags.HasFlags(FmtHideConstants) { + ctx.WriteByte('_') + } else { + lex.EncodeSQLStringWithFlags(&ctx.Buffer, *n.Comment, ctx.flags.EncodeFlags()) + } } else { ctx.WriteString("NULL") } diff --git a/pkg/sql/sem/tree/copy.go b/pkg/sql/sem/tree/copy.go index d460fb8bc975..1bdd2ff78f61 100644 --- a/pkg/sql/sem/tree/copy.go +++ b/pkg/sql/sem/tree/copy.go @@ -70,13 +70,13 @@ func (o *CopyOptions) Format(ctx *FmtCtx) { if o.Delimiter != nil { maybeAddSep() ctx.WriteString("DELIMITER ") - o.Delimiter.Format(ctx) + ctx.FormatNode(o.Delimiter) addSep = true } if o.Null != nil { maybeAddSep() ctx.WriteString("NULL ") - o.Null.Format(ctx) + ctx.FormatNode(o.Null) addSep = true } if o.Destination != nil { @@ -85,7 +85,7 @@ func (o *CopyOptions) Format(ctx *FmtCtx) { // by copy_file_upload.go, so this will provide backward // compatibility with older servers. ctx.WriteString("destination = ") - o.Destination.Format(ctx) + ctx.FormatNode(o.Destination) addSep = true } } diff --git a/pkg/sql/sem/tree/create.go b/pkg/sql/sem/tree/create.go index b5116f8d4fdf..f7d5e9f352f1 100644 --- a/pkg/sql/sem/tree/create.go +++ b/pkg/sql/sem/tree/create.go @@ -59,36 +59,57 @@ func (node *CreateDatabase) Format(ctx *FmtCtx) { } ctx.FormatNode(&node.Name) if node.Template != "" { + // NB: the template is not currently edited out under FmtAnonymize, + // because we don't support custom templates. If/when custom + // templates are supported, this should call ctx.FormatNode + // on the template expr. ctx.WriteString(" TEMPLATE = ") lex.EncodeSQLStringWithFlags(&ctx.Buffer, node.Template, ctx.flags.EncodeFlags()) } if node.Encoding != "" { + // NB: the encoding is not currently edited out under FmtAnonymize, + // because we don't support custom encodings. If/when custom + // encodings are supported, this should call ctx.FormatNode + // on the encoding expr. ctx.WriteString(" ENCODING = ") lex.EncodeSQLStringWithFlags(&ctx.Buffer, node.Encoding, ctx.flags.EncodeFlags()) } if node.Collate != "" { + // NB: the collation is not currently edited out under FmtAnonymize, + // because we don't support custom collations. If/when custom + // collations are supported, this should call ctx.FormatNode + // on the collation expr. ctx.WriteString(" LC_COLLATE = ") lex.EncodeSQLStringWithFlags(&ctx.Buffer, node.Collate, ctx.flags.EncodeFlags()) } if node.CType != "" { + // NB: the ctype (formatting customization) is not currently + // edited out under FmtAnonymize, because we don't support custom + // cutomizations. If/when custom customizations are supported, + // this should call ctx.FormatNode on the ctype expr. ctx.WriteString(" LC_CTYPE = ") lex.EncodeSQLStringWithFlags(&ctx.Buffer, node.CType, ctx.flags.EncodeFlags()) } if node.ConnectionLimit != -1 { ctx.WriteString(" CONNECTION LIMIT = ") - ctx.WriteString(strconv.Itoa(int(node.ConnectionLimit))) + if ctx.flags.HasFlags(FmtHideConstants) { + ctx.WriteByte('_') + } else { + // NB: use ctx.FormatNode when the connection limit becomes an expression. + ctx.WriteString(strconv.Itoa(int(node.ConnectionLimit))) + } } if node.PrimaryRegion != "" { ctx.WriteString(" PRIMARY REGION ") - node.PrimaryRegion.Format(ctx) + ctx.FormatNode(&node.PrimaryRegion) } if node.Regions != nil { ctx.WriteString(" REGIONS = ") - node.Regions.Format(ctx) + ctx.FormatNode(&node.Regions) } if node.SurvivalGoal != SurvivalGoalDefault { ctx.WriteString(" ") - node.SurvivalGoal.Format(ctx) + ctx.FormatNode(&node.SurvivalGoal) } } @@ -1261,6 +1282,8 @@ func (o *StorageParams) Format(ctx *FmtCtx) { if i > 0 { ctx.WriteString(", ") } + // TODO(knz): the key may need to be formatted differently + // if we want to de-anonymize it. ctx.FormatNode(&n.Key) if n.Value != nil { ctx.WriteString(` = `) @@ -1360,7 +1383,7 @@ func (node *CreateTable) FormatBody(ctx *FmtCtx) { // parameters in the output format. if node.Locality != nil { ctx.WriteString(" ") - node.Locality.Format(ctx) + ctx.FormatNode(node.Locality) } } } @@ -1491,7 +1514,13 @@ func (node *SequenceOptions) Format(ctx *FmtCtx) { case SeqOptCache: ctx.WriteString(option.Name) ctx.WriteByte(' ') - ctx.Printf("%d", *option.IntVal) + // TODO(knz): replace all this with ctx.FormatNode if/when + // the cache option supports expressions. + if ctx.flags.HasFlags(FmtHideConstants) { + ctx.WriteByte('_') + } else { + ctx.Printf("%d", *option.IntVal) + } case SeqOptMaxValue, SeqOptMinValue: if option.IntVal == nil { ctx.WriteString("NO ") @@ -1499,7 +1528,13 @@ func (node *SequenceOptions) Format(ctx *FmtCtx) { } else { ctx.WriteString(option.Name) ctx.WriteByte(' ') - ctx.Printf("%d", *option.IntVal) + // TODO(knz): replace all this with ctx.FormatNode if/when + // the min/max value options support expressions. + if ctx.flags.HasFlags(FmtHideConstants) { + ctx.WriteByte('_') + } else { + ctx.Printf("%d", *option.IntVal) + } } case SeqOptStart: ctx.WriteString(option.Name) @@ -1507,14 +1542,26 @@ func (node *SequenceOptions) Format(ctx *FmtCtx) { if option.OptionalWord { ctx.WriteString("WITH ") } - ctx.Printf("%d", *option.IntVal) + // TODO(knz): replace all this with ctx.FormatNode if/when + // the start option supports expressions. + if ctx.flags.HasFlags(FmtHideConstants) { + ctx.WriteByte('_') + } else { + ctx.Printf("%d", *option.IntVal) + } case SeqOptIncrement: ctx.WriteString(option.Name) ctx.WriteByte(' ') if option.OptionalWord { ctx.WriteString("BY ") } - ctx.Printf("%d", *option.IntVal) + // TODO(knz): replace all this with ctx.FormatNode if/when + // the increment option supports expressions. + if ctx.flags.HasFlags(FmtHideConstants) { + ctx.WriteByte('_') + } else { + ctx.Printf("%d", *option.IntVal) + } case SeqOptVirtual: ctx.WriteString(option.Name) case SeqOptOwnedBy: @@ -1687,16 +1734,13 @@ func (o *KVOptions) formatAsRoleOptions(ctx *FmtCtx) { ) // Password is a special case. - if strings.ToUpper(option.Key.String()) == "PASSWORD" { + if strings.ToUpper(option.Key.String()) == "PASSWORD" && option.Value != DNull { ctx.WriteString(" ") if ctx.flags.HasFlags(FmtShowPasswords) { ctx.FormatNode(option.Value) } else { - ctx.WriteString("*****") + ctx.WriteString(PasswordSubstitution) } - } else if option.Value == DNull { - ctx.WriteString(" ") - ctx.FormatNode(option.Value) } else if option.Value != nil { ctx.WriteString(" ") ctx.FormatNode(option.Value) @@ -1895,7 +1939,14 @@ func (o *CreateStatsOptions) Empty() bool { func (o *CreateStatsOptions) Format(ctx *FmtCtx) { sep := "" if o.Throttling != 0 { - fmt.Fprintf(ctx, "THROTTLING %g", o.Throttling) + ctx.WriteString("THROTTLING ") + // TODO(knz): Remove all this with ctx.FormatNode() + // if/when throttling supports full expressions. + if ctx.flags.HasFlags(FmtHideConstants) { + ctx.WriteByte('_') + } else { + fmt.Fprintf(ctx, "%g", o.Throttling) + } sep = " " } if o.AsOf.Expr != nil { @@ -1935,5 +1986,10 @@ func (node *CreateExtension) Format(ctx *FmtCtx) { if node.IfNotExists { ctx.WriteString("IF NOT EXISTS ") } + // NB: we do not anonymize the extension name + // because 1) we assume that extension names + // do not contain sensitive information and + // 2) we want to get telemetry on which extensions + // users attempt to load. ctx.WriteString(node.Name) } diff --git a/pkg/sql/sem/tree/datum.go b/pkg/sql/sem/tree/datum.go index 6d3479e5a66c..085127bacc12 100644 --- a/pkg/sql/sem/tree/datum.go +++ b/pkg/sql/sem/tree/datum.go @@ -3272,6 +3272,8 @@ func (d *DJSON) Format(ctx *FmtCtx) { if ctx.flags.HasFlags(fmtRawStrings) { ctx.WriteString(s) } else { + // TODO(knz): This seems incorrect, + // see https://github.com/cockroachdb/cockroach/issues/60673 lex.EncodeSQLStringWithFlags(&ctx.Buffer, s, ctx.flags.EncodeFlags()) } } diff --git a/pkg/sql/sem/tree/expr.go b/pkg/sql/sem/tree/expr.go index 0c3b0fb35ba6..60c687047e00 100644 --- a/pkg/sql/sem/tree/expr.go +++ b/pkg/sql/sem/tree/expr.go @@ -1708,7 +1708,7 @@ type ColumnAccessExpr struct { // ColName is the name of the column to access. Empty if ByIndex is // set. - ColName string + ColName Name // ColIndex indicates the index of the column in the tuple. This is // either: @@ -1724,7 +1724,7 @@ type ColumnAccessExpr struct { // NewTypedColumnAccessExpr creates a pre-typed ColumnAccessExpr. // A by-index ColumnAccessExpr can be specified by passing an empty string as colName. -func NewTypedColumnAccessExpr(expr TypedExpr, colName string, colIdx int) *ColumnAccessExpr { +func NewTypedColumnAccessExpr(expr TypedExpr, colName Name, colIdx int) *ColumnAccessExpr { return &ColumnAccessExpr{ Expr: expr, ColName: colName, @@ -1742,7 +1742,7 @@ func (node *ColumnAccessExpr) Format(ctx *FmtCtx) { if node.ByIndex { fmt.Fprintf(ctx, "@%d", node.ColIndex+1) } else { - ctx.WriteString(node.ColName) + ctx.FormatNode(&node.ColName) } } diff --git a/pkg/sql/sem/tree/format.go b/pkg/sql/sem/tree/format.go index 7d09d8348894..04c04a5a311a 100644 --- a/pkg/sql/sem/tree/format.go +++ b/pkg/sql/sem/tree/format.go @@ -139,6 +139,10 @@ const ( fmtFormatByteLiterals ) +// PasswordSubstitution is the string that replaces +// passwords unless FmtShowPasswords is specified. +const PasswordSubstitution = "'*****'" + // Composite/derived flag definitions follow. const ( // FmtPgwireText instructs the pretty-printer to use diff --git a/pkg/sql/sem/tree/format_test.go b/pkg/sql/sem/tree/format_test.go index 0d6ea0befad7..c198a5c731a7 100644 --- a/pkg/sql/sem/tree/format_test.go +++ b/pkg/sql/sem/tree/format_test.go @@ -35,52 +35,6 @@ func TestFormatStatement(t *testing.T) { f tree.FmtFlags expected string }{ - {`CREATE USER foo WITH PASSWORD 'bar'`, tree.FmtSimple, - `CREATE USER 'foo' WITH PASSWORD *****`}, - {`CREATE USER foo WITH PASSWORD 'bar'`, tree.FmtShowPasswords, - `CREATE USER 'foo' WITH PASSWORD 'bar'`}, - - {`CREATE TABLE foo (x INT8)`, tree.FmtAnonymize, - `CREATE TABLE _ (_ INT8)`}, - {`INSERT INTO foo(x) TABLE bar`, tree.FmtAnonymize, - `INSERT INTO _(_) TABLE _`}, - {`UPDATE foo SET x = y`, tree.FmtAnonymize, - `UPDATE _ SET _ = _`}, - {`DELETE FROM foo`, tree.FmtAnonymize, - `DELETE FROM _`}, - {`TRUNCATE foo`, tree.FmtAnonymize, - `TRUNCATE TABLE _`}, - {`ALTER TABLE foo RENAME TO bar`, tree.FmtAnonymize, - `ALTER TABLE _ RENAME TO _`}, - {`SHOW COLUMNS FROM foo`, tree.FmtAnonymize, - `SHOW COLUMNS FROM _`}, - {`SHOW CREATE TABLE foo`, tree.FmtAnonymize, - `SHOW CREATE _`}, - {`GRANT SELECT ON bar TO foo`, tree.FmtAnonymize, - `GRANT SELECT ON TABLE _ TO _`}, - - {`INSERT INTO a VALUES (-2, +3)`, - tree.FmtHideConstants, - `INSERT INTO a VALUES (_, _)`}, - - {`INSERT INTO a VALUES (0), (0), (0), (0), (0), (0)`, - tree.FmtHideConstants, - `INSERT INTO a VALUES (_), (__more5__)`}, - {`INSERT INTO a VALUES (0, 0, 0, 0, 0, 0)`, - tree.FmtHideConstants, - `INSERT INTO a VALUES (_, _, __more4__)`}, - {`INSERT INTO a VALUES (ARRAY[0, 0, 0, 0, 0, 0, 0])`, - tree.FmtHideConstants, - `INSERT INTO a VALUES (ARRAY[_, _, __more5__])`}, - {`INSERT INTO a VALUES (ARRAY[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ` + - `0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ` + - `0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])`, - tree.FmtHideConstants, - `INSERT INTO a VALUES (ARRAY[_, _, __more30__])`}, - - {`SELECT 1+COALESCE(NULL, 'a', x)-ARRAY[3.14]`, tree.FmtHideConstants, - `SELECT (_ + COALESCE(_, _, x)) - ARRAY[_]`}, - // This here checks encodeSQLString on non-tree.DString strings also // calls encodeSQLString with the right formatter. // See TestFormatExprs below for the test on DStrings. @@ -99,41 +53,6 @@ func TestFormatStatement(t *testing.T) { `SET time zone = utc`}, {`SET "time zone" = UTC`, tree.FmtBareStrings, `SET "time zone" = utc`}, - - // Test schema anonymization. - {`CREATE SCHEMA s`, tree.FmtAnonymize, - `CREATE SCHEMA _`}, - {`ALTER SCHEMA s1 RENAME TO s2`, tree.FmtAnonymize, - `ALTER SCHEMA _ RENAME TO _`}, - {`DROP SCHEMA a, b`, tree.FmtAnonymize, - `DROP SCHEMA _, _`}, - {`GRANT SELECT ON SCHEMA a TO b, c`, tree.FmtAnonymize, - `GRANT SELECT ON SCHEMA _ TO _, _`}, - {`ALTER TYPE t SET SCHEMA s`, tree.FmtAnonymize, - `ALTER TYPE _ SET SCHEMA _`}, - - // Test owner anonymization. - {`ALTER DATABASE d OWNER TO o`, tree.FmtAnonymize, - `ALTER DATABASE _ OWNER TO _`}, - {`ALTER SCHEMA s OWNER TO o`, tree.FmtAnonymize, - `ALTER SCHEMA _ OWNER TO _`}, - - // Test ENUM anonymization. - {`CREATE TYPE a AS ENUM ('a', 'b', 'c')`, tree.FmtAnonymize, - `CREATE TYPE _ AS ENUM (_, _, _)`}, - {`ALTER TYPE a ADD VALUE 'hi' BEFORE 'hello'`, tree.FmtAnonymize, - `ALTER TYPE _ ADD VALUE _ BEFORE _`}, - {`ALTER TYPE a DROP VALUE 'hi'`, tree.FmtAnonymize, - `ALTER TYPE _ DROP VALUE _`}, - {`ALTER TYPE a RENAME VALUE 'value1' TO 'value2'`, tree.FmtAnonymize, - `ALTER TYPE _ RENAME VALUE _ TO _`}, - - {`RESTORE abc.xzy FROM 'a' WITH into_db='foo', skip_missing_foreign_keys`, - tree.FmtHideConstants | tree.FmtAnonymize, - `RESTORE TABLE _._ FROM _ WITH into_db=_, skip_missing_foreign_keys`}, - {`RESTORE FROM 'a' WITH into_db='foo', skip_missing_foreign_keys`, - tree.FmtHideConstants | tree.FmtAnonymize, - `RESTORE FROM _ WITH into_db=_, skip_missing_foreign_keys`}, } for i, test := range testData { diff --git a/pkg/sql/sem/tree/indexed_vars.go b/pkg/sql/sem/tree/indexed_vars.go index 2fedca69255c..d1b80bcad200 100644 --- a/pkg/sql/sem/tree/indexed_vars.go +++ b/pkg/sql/sem/tree/indexed_vars.go @@ -97,7 +97,7 @@ func (v *IndexedVar) Format(ctx *FmtCtx) { } else if f.HasFlags(fmtSymbolicVars) || v.col == nil { ctx.Printf("@%d", v.Idx+1) } else { - v.col.Format(ctx) + ctx.FormatNode(v.col) } } diff --git a/pkg/sql/sem/tree/region.go b/pkg/sql/sem/tree/region.go index aae07137e301..cf551ef9ce20 100644 --- a/pkg/sql/sem/tree/region.go +++ b/pkg/sql/sem/tree/region.go @@ -94,7 +94,7 @@ func (node *Locality) Format(ctx *FmtCtx) { case LocalityLevelTable: ctx.WriteString("REGIONAL BY TABLE IN ") if node.TableRegion != "" { - node.TableRegion.Format(ctx) + ctx.FormatNode(&node.TableRegion) } else { ctx.WriteString("PRIMARY REGION") } @@ -102,7 +102,7 @@ func (node *Locality) Format(ctx *FmtCtx) { ctx.WriteString("REGIONAL BY ROW") if node.RegionalByRowColumn != "" { ctx.WriteString(" AS ") - node.RegionalByRowColumn.Format(ctx) + ctx.FormatNode(&node.RegionalByRowColumn) } default: panic(fmt.Sprintf("unknown locality: %#v", node.LocalityLevel)) diff --git a/pkg/sql/sem/tree/rename.go b/pkg/sql/sem/tree/rename.go index 1f6766325b57..850b2f452608 100644 --- a/pkg/sql/sem/tree/rename.go +++ b/pkg/sql/sem/tree/rename.go @@ -42,9 +42,9 @@ type ReparentDatabase struct { // Format implements the NodeFormatter interface. func (node *ReparentDatabase) Format(ctx *FmtCtx) { ctx.WriteString("ALTER DATABASE ") - node.Name.Format(ctx) + ctx.FormatNode(&node.Name) ctx.WriteString(" CONVERT TO SCHEMA WITH PARENT ") - node.Parent.Format(ctx) + ctx.FormatNode(&node.Parent) } // RenameTable represents a RENAME TABLE or RENAME VIEW or RENAME SEQUENCE diff --git a/pkg/sql/sem/tree/revoke.go b/pkg/sql/sem/tree/revoke.go index e68ba4aaa509..813661ac5df9 100644 --- a/pkg/sql/sem/tree/revoke.go +++ b/pkg/sql/sem/tree/revoke.go @@ -32,6 +32,9 @@ type Revoke struct { // Format implements the NodeFormatter interface. func (node *Revoke) Format(ctx *FmtCtx) { ctx.WriteString("REVOKE ") + // NB: we cannot use FormatNode() here because node.Privileges is + // not an AST node. This is OK, because a privilege list cannot + // contain sensitive information. node.Privileges.Format(&ctx.Buffer) ctx.WriteString(" ON ") ctx.FormatNode(&node.Targets) diff --git a/pkg/sql/sem/tree/run_control.go b/pkg/sql/sem/tree/run_control.go index 0794cefbf1e6..b635852457a9 100644 --- a/pkg/sql/sem/tree/run_control.go +++ b/pkg/sql/sem/tree/run_control.go @@ -10,8 +10,6 @@ package tree -import "fmt" - // ControlJobs represents a PAUSE/RESUME/CANCEL JOBS statement. type ControlJobs struct { Jobs *Select @@ -103,10 +101,11 @@ type ControlSchedules struct { var _ Statement = &ControlSchedules{} -// Format implements NodeFormatter interface +// Format implements the NodeFormatter interface. func (n *ControlSchedules) Format(ctx *FmtCtx) { - fmt.Fprintf(ctx, "%s SCHEDULES ", n.Command) - n.Schedules.Format(ctx) + ctx.WriteString(n.Command.String()) + ctx.WriteString(" SCHEDULES ") + ctx.FormatNode(n.Schedules) } // ControlJobsForSchedules represents PAUSE/RESUME/CANCEL clause @@ -116,10 +115,11 @@ type ControlJobsForSchedules struct { Command JobCommand } -// Format implements NodeFormatter interface +// Format implements NodeFormatter interface. func (n *ControlJobsForSchedules) Format(ctx *FmtCtx) { - fmt.Fprintf(ctx, "%s JOBS FOR SCHEDULES %s", - JobCommandToStatement[n.Command], AsString(n.Schedules)) + ctx.WriteString(JobCommandToStatement[n.Command]) + ctx.WriteString(" JOBS FOR SCHEDULES ") + ctx.FormatNode(n.Schedules) } var _ Statement = &ControlJobsForSchedules{} diff --git a/pkg/sql/sem/tree/schedule.go b/pkg/sql/sem/tree/schedule.go index 169bedd34bb0..e89e3c6bbf0f 100644 --- a/pkg/sql/sem/tree/schedule.go +++ b/pkg/sql/sem/tree/schedule.go @@ -35,13 +35,13 @@ func (node *ScheduledBackup) Format(ctx *FmtCtx) { if node.ScheduleLabel != nil { ctx.WriteString(" ") - node.ScheduleLabel.Format(ctx) + ctx.FormatNode(node.ScheduleLabel) } ctx.WriteString(" FOR BACKUP") if node.Targets != nil { ctx.WriteString(" ") - node.Targets.Format(ctx) + ctx.FormatNode(node.Targets) } ctx.WriteString(" INTO ") @@ -49,21 +49,21 @@ func (node *ScheduledBackup) Format(ctx *FmtCtx) { if !node.BackupOptions.IsDefault() { ctx.WriteString(" WITH ") - node.BackupOptions.Format(ctx) + ctx.FormatNode(&node.BackupOptions) } ctx.WriteString(" RECURRING ") if node.Recurrence == nil { ctx.WriteString("NEVER") } else { - node.Recurrence.Format(ctx) + ctx.FormatNode(node.Recurrence) } if node.FullBackup != nil { if node.FullBackup.Recurrence != nil { ctx.WriteString(" FULL BACKUP ") - node.FullBackup.Recurrence.Format(ctx) + ctx.FormatNode(node.FullBackup.Recurrence) } else if node.FullBackup.AlwaysFull { ctx.WriteString(" FULL BACKUP ALWAYS") } @@ -71,6 +71,6 @@ func (node *ScheduledBackup) Format(ctx *FmtCtx) { if node.ScheduleOptions != nil { ctx.WriteString(" WITH SCHEDULE OPTIONS ") - node.ScheduleOptions.Format(ctx) + ctx.FormatNode(&node.ScheduleOptions) } } diff --git a/pkg/sql/sem/tree/scrub.go b/pkg/sql/sem/tree/scrub.go index 03a0f2e96002..98cb560cd4f3 100644 --- a/pkg/sql/sem/tree/scrub.go +++ b/pkg/sql/sem/tree/scrub.go @@ -39,7 +39,7 @@ func (n *Scrub) Format(ctx *FmtCtx) { switch n.Typ { case ScrubTable: ctx.WriteString("TABLE ") - n.Table.Format(ctx) + ctx.FormatNode(n.Table) case ScrubDatabase: ctx.WriteString("DATABASE ") ctx.FormatNode(&n.Database) diff --git a/pkg/sql/sem/tree/select.go b/pkg/sql/sem/tree/select.go index 9af7231e4736..21b5613c7aa4 100644 --- a/pkg/sql/sem/tree/select.go +++ b/pkg/sql/sem/tree/select.go @@ -994,12 +994,12 @@ type LockingItem struct { // Format implements the NodeFormatter interface. func (f *LockingItem) Format(ctx *FmtCtx) { - f.Strength.Format(ctx) + ctx.FormatNode(f.Strength) if len(f.Targets) > 0 { ctx.WriteString(" OF ") - f.Targets.Format(ctx) + ctx.FormatNode(&f.Targets) } - f.WaitPolicy.Format(ctx) + ctx.FormatNode(f.WaitPolicy) } // LockingStrength represents the possible row-level lock modes for a SELECT diff --git a/pkg/sql/sem/tree/set.go b/pkg/sql/sem/tree/set.go index d7142d5a6e91..a6d987d43c3b 100644 --- a/pkg/sql/sem/tree/set.go +++ b/pkg/sql/sem/tree/set.go @@ -71,7 +71,7 @@ type SetTransaction struct { // Format implements the NodeFormatter interface. func (node *SetTransaction) Format(ctx *FmtCtx) { ctx.WriteString("SET TRANSACTION") - node.Modes.Format(ctx) + ctx.FormatNode(&node.Modes) } // SetSessionAuthorizationDefault represents a SET SESSION AUTHORIZATION DEFAULT @@ -92,7 +92,7 @@ type SetSessionCharacteristics struct { // Format implements the NodeFormatter interface. func (node *SetSessionCharacteristics) Format(ctx *FmtCtx) { ctx.WriteString("SET SESSION CHARACTERISTICS AS TRANSACTION") - node.Modes.Format(ctx) + ctx.FormatNode(&node.Modes) } // SetTracing represents a SET TRACING statement. diff --git a/pkg/sql/sem/tree/show.go b/pkg/sql/sem/tree/show.go index f9e8ae0b3d14..b95c017148ab 100644 --- a/pkg/sql/sem/tree/show.go +++ b/pkg/sql/sem/tree/show.go @@ -280,7 +280,7 @@ func (node *ShowJobs) Format(ctx *FmtCtx) { } if node.Schedules != nil { ctx.WriteString(" FOR SCHEDULES ") - node.Schedules.Format(ctx) + ctx.FormatNode(node.Schedules) } } @@ -294,7 +294,7 @@ func (node *ShowSurvivalGoal) Format(ctx *FmtCtx) { ctx.WriteString("SHOW SURVIVAL GOAL FROM DATABASE") if node.DatabaseName != "" { ctx.WriteString(" ") - node.DatabaseName.Format(ctx) + ctx.FormatNode(&node.DatabaseName) } } @@ -329,7 +329,7 @@ func (node *ShowRegions) Format(ctx *FmtCtx) { ctx.WriteString(" FROM DATABASE") if node.DatabaseName != "" { ctx.WriteString(" ") - node.DatabaseName.Format(ctx) + ctx.FormatNode(&node.DatabaseName) } case ShowRegionsFromCluster: ctx.WriteString(" FROM CLUSTER") @@ -504,7 +504,11 @@ type ShowSyntax struct { // Format implements the NodeFormatter interface. func (node *ShowSyntax) Format(ctx *FmtCtx) { ctx.WriteString("SHOW SYNTAX ") - ctx.WriteString(lex.EscapeSQLString(node.Statement)) + if ctx.flags.HasFlags(FmtAnonymize) || ctx.flags.HasFlags(FmtHideConstants) { + ctx.WriteByte('_') + } else { + ctx.WriteString(lex.EscapeSQLString(node.Statement)) + } } // ShowTransactionStatus represents a SHOW TRANSACTION STATUS statement. @@ -729,19 +733,22 @@ var _ Statement = &ShowSchedules{} // Format implements the NodeFormatter interface. func (n *ShowSchedules) Format(ctx *FmtCtx) { if n.ScheduleID != nil { - ctx.Printf("SHOW SCHEDULE %s", AsString(n.ScheduleID)) + ctx.WriteString("SHOW SCHEDULE ") + ctx.FormatNode(n.ScheduleID) return } ctx.Printf("SHOW") if n.WhichSchedules != SpecifiedSchedules { ctx.WriteString(" ") - n.WhichSchedules.Format(ctx) + ctx.FormatNode(&n.WhichSchedules) } ctx.Printf(" SCHEDULES") if n.ExecutorType != InvalidExecutor { + // TODO(knz): beware of using ctx.FormatNode here if + // FOR changes to support expressions. ctx.Printf(" FOR %s", n.ExecutorType.UserName()) } } diff --git a/pkg/sql/sem/tree/testdata/pretty/restore.align-deindent.golden.short b/pkg/sql/sem/tree/testdata/pretty/restore.align-deindent.golden.short index 48abbf02d762..4fc3b3a7209d 100644 --- a/pkg/sql/sem/tree/testdata/pretty/restore.align-deindent.golden.short +++ b/pkg/sql/sem/tree/testdata/pretty/restore.align-deindent.golden.short @@ -8,6 +8,6 @@ 'gs://acme-co-backup/database-bank-2017-03-28-nightly', 'gs://acme-co-backup/database-bank-2017-03-29-nightly' AS OF SYSTEM TIME '2017-02-28 10:00:00' - WITH into_db='newdb' + WITH into_db = 'newdb' diff --git a/pkg/sql/sem/tree/testdata/pretty/restore.align-only.golden.short b/pkg/sql/sem/tree/testdata/pretty/restore.align-only.golden.short index 48abbf02d762..4fc3b3a7209d 100644 --- a/pkg/sql/sem/tree/testdata/pretty/restore.align-only.golden.short +++ b/pkg/sql/sem/tree/testdata/pretty/restore.align-only.golden.short @@ -8,6 +8,6 @@ 'gs://acme-co-backup/database-bank-2017-03-28-nightly', 'gs://acme-co-backup/database-bank-2017-03-29-nightly' AS OF SYSTEM TIME '2017-02-28 10:00:00' - WITH into_db='newdb' + WITH into_db = 'newdb' diff --git a/pkg/sql/sem/tree/testdata/pretty/restore.ref.golden.short b/pkg/sql/sem/tree/testdata/pretty/restore.ref.golden.short index 8e589e548ad2..6d993dd5799d 100644 --- a/pkg/sql/sem/tree/testdata/pretty/restore.ref.golden.short +++ b/pkg/sql/sem/tree/testdata/pretty/restore.ref.golden.short @@ -12,6 +12,6 @@ FROM AS OF SYSTEM TIME '2017-02-28 10:00:00' WITH - into_db='newdb' + into_db = 'newdb' diff --git a/pkg/sql/sem/tree/txn.go b/pkg/sql/sem/tree/txn.go index 7145ba75d4a5..5fa7e191395c 100644 --- a/pkg/sql/sem/tree/txn.go +++ b/pkg/sql/sem/tree/txn.go @@ -157,7 +157,7 @@ func (node *TransactionModes) Format(ctx *FmtCtx) { if node.AsOf.Expr != nil { ctx.WriteString(sep) ctx.WriteString(" ") - node.AsOf.Format(ctx) + ctx.FormatNode(&node.AsOf) sep = "," } if node.Deferrable != UnspecifiedDeferrableMode { @@ -227,7 +227,7 @@ type BeginTransaction struct { // Format implements the NodeFormatter interface. func (node *BeginTransaction) Format(ctx *FmtCtx) { ctx.WriteString("BEGIN TRANSACTION") - node.Modes.Format(ctx) + ctx.FormatNode(&node.Modes) } // CommitTransaction represents a COMMIT statement. @@ -254,7 +254,7 @@ type Savepoint struct { // Format implements the NodeFormatter interface. func (node *Savepoint) Format(ctx *FmtCtx) { ctx.WriteString("SAVEPOINT ") - node.Name.Format(ctx) + ctx.FormatNode(&node.Name) } // ReleaseSavepoint represents a RELEASE SAVEPOINT statement. @@ -265,7 +265,7 @@ type ReleaseSavepoint struct { // Format implements the NodeFormatter interface. func (node *ReleaseSavepoint) Format(ctx *FmtCtx) { ctx.WriteString("RELEASE SAVEPOINT ") - node.Savepoint.Format(ctx) + ctx.FormatNode(&node.Savepoint) } // RollbackToSavepoint represents a ROLLBACK TO SAVEPOINT statement. @@ -276,5 +276,5 @@ type RollbackToSavepoint struct { // Format implements the NodeFormatter interface. func (node *RollbackToSavepoint) Format(ctx *FmtCtx) { ctx.WriteString("ROLLBACK TRANSACTION TO SAVEPOINT ") - node.Savepoint.Format(ctx) + ctx.FormatNode(&node.Savepoint) } diff --git a/pkg/sql/sem/tree/type_check.go b/pkg/sql/sem/tree/type_check.go index ebd424bb004e..30a60012861a 100644 --- a/pkg/sql/sem/tree/type_check.go +++ b/pkg/sql/sem/tree/type_check.go @@ -668,7 +668,7 @@ func (expr *ColumnAccessExpr) TypeCheck( // Go through all of the labels to find a match. expr.ColIndex = -1 for i, label := range resolvedType.TupleLabels() { - if label == expr.ColName { + if label == string(expr.ColName) { if expr.ColIndex != -1 { // Found a duplicate label. return nil, pgerror.Newf(pgcode.AmbiguousColumn, "column reference %q is ambiguous", label) @@ -679,7 +679,7 @@ func (expr *ColumnAccessExpr) TypeCheck( if expr.ColIndex < 0 { return nil, pgerror.Newf(pgcode.DatatypeMismatch, "could not identify column %q in %s", - ErrNameStringP(&expr.ColName), resolvedType, + ErrString(&expr.ColName), resolvedType, ) } } diff --git a/pkg/sql/sem/tree/type_name.go b/pkg/sql/sem/tree/type_name.go index dc9f30b72c4f..d92d3cc04a4c 100644 --- a/pkg/sql/sem/tree/type_name.go +++ b/pkg/sql/sem/tree/type_name.go @@ -42,7 +42,7 @@ func (t *TypeName) Type() string { // Format implements the NodeFormatter interface. func (t *TypeName) Format(ctx *FmtCtx) { - t.ObjectNamePrefix.Format(ctx) + ctx.FormatNode(&t.ObjectNamePrefix) if t.ExplicitSchema || ctx.alwaysFormatTablePrefix() { ctx.WriteByte('.') } diff --git a/pkg/sql/sem/tree/var_name.go b/pkg/sql/sem/tree/var_name.go index dcdc69c0ede1..735a57fc90ac 100644 --- a/pkg/sql/sem/tree/var_name.go +++ b/pkg/sql/sem/tree/var_name.go @@ -134,7 +134,7 @@ type ColumnItem struct { // If this is updated, then dummyColumnItem.Format should be updated as well. func (c *ColumnItem) Format(ctx *FmtCtx) { if c.TableName != nil { - c.TableName.Format(ctx) + ctx.FormatNode(c.TableName) ctx.WriteByte('.') } ctx.FormatNode(&c.ColumnName)